blob: 0c732b6eb182448a1110759f623702bbf01bf7d1 [file] [log] [blame]
Lele Liu5767b162023-02-22 19:45:13 +08001#Copyright (C) 2018 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15function auto_patch()
16{
17 local patch_dir=$1
18
19 for file in $patch_dir/*
20 do
21 if [ -f "$file" ] && [ "${file##*.}" == "patch" ]
22 then
23 local file_name=${file%.*}; #echo file_name $file_name
24 local resFile=`basename $file_name`; #echo resFile $resFile
25 local dir_name1=${resFile//#/\/}; #echo dir_name $dir_name
26 local dir_name=${dir_name1%/*}; #echo dir_name $dir_name
27 local dir=$ROOT_DIR/$dir_name; #echo $dir
28 local change_id=`grep 'Change-Id' $file | head -n1 | awk '{print $2}'`
29 echo "debug: $file_name $resFile $dir_name1 $dirname $dir $change_id"
30 if [ -d "$dir" ]
31 then
32 cd $dir; git log -n 100 | grep $change_id 1>/dev/null 2>&1;
33 if [ $? -ne 0 ]; then
34 echo "###patch ${file##*/}### "
35 cd $dir; git am -q $file 1>/dev/null 2>&1;
36 if [ $? != 0 ]
37 then
38 git am --abort
39 echo " Error : Failed to patch [$file], Need check it.exit"
40 exit
41 fi
42 fi
43 fi
44 fi
45 done
46}
47
48function traverse_patch_dir()
49{
50 local local_dir=$1
51 for file in `ls $local_dir`
52 do
53 if [ -d $local_dir$file ]
54 then
55 local dest_dir=$local_dir$file
56 auto_patch $dest_dir
57 fi
58 done
59 echo " Patch Finish."
60 cd $UBOOT_DIR
61}
62
63CURRENT_DIR=$(pwd)/../../device/sei/adt4/pre_submit_for_adt4
64echo "debug: $CURRENT_DIR"
65LOCAL_PATH=$CURRENT_DIR/$(dirname $0)/
66ROOT_DIR=$(pwd)/../..
67UBOOT_DIR=$ROOT_DIR/bootloader/uboot-repo
68
69if [ -d "$CURRENT_DIR" ]
70then
71 echo ""
72 traverse_patch_dir $LOCAL_PATH
73fi
74
75if [ $? != 0 ]
76then
77 echo "patch error"
78 return 1
79fi