Lele Liu | 5767b16 | 2023-02-22 19:45:13 +0800 | [diff] [blame] | 1 | #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 | |
| 15 | function 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 | |
| 48 | function 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 | |
| 63 | CURRENT_DIR=$(pwd)/../../device/sei/adt4/pre_submit_for_adt4 |
| 64 | echo "debug: $CURRENT_DIR" |
| 65 | LOCAL_PATH=$CURRENT_DIR/$(dirname $0)/ |
| 66 | ROOT_DIR=$(pwd)/../.. |
| 67 | UBOOT_DIR=$ROOT_DIR/bootloader/uboot-repo |
| 68 | |
| 69 | if [ -d "$CURRENT_DIR" ] |
| 70 | then |
| 71 | echo "" |
| 72 | traverse_patch_dir $LOCAL_PATH |
| 73 | fi |
| 74 | |
| 75 | if [ $? != 0 ] |
| 76 | then |
| 77 | echo "patch error" |
| 78 | return 1 |
| 79 | fi |