File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,9 +34,40 @@ if [ -z "${PATCH_DIR}" ]; then
3434 exit 255
3535fi
3636
37+ patch_targets_workspace () {
38+ local patch_file=$1
39+ local candidate_path=" "
40+ local repo_path=" "
41+ local saw_diff=0
42+
43+ while read -r _ _ old_path new_path; do
44+ saw_diff=1
45+ old_path=${old_path# a/ }
46+ new_path=${new_path# b/ }
47+
48+ for candidate_path in " ${old_path} " " ${new_path} " ; do
49+ repo_path=$( printf ' %s\n' " ${candidate_path} " | cut -d/ -f1-2)
50+ if [ -n " ${repo_path} " ] && [ -d " ${WORKSPACE_DIR} /${repo_path} " ]; then
51+ return 0
52+ fi
53+ done
54+ done < <( grep ' ^diff --git a/' " ${patch_file} " || true)
55+
56+ if [ " ${saw_diff} " -eq 0 ]; then
57+ return 0
58+ fi
59+
60+ return 1
61+ }
62+
3763apply_patch_file () {
3864 local patch_file=$1
3965
66+ if ! patch_targets_workspace " ${patch_file} " ; then
67+ echo " Skipping $( basename " ${patch_file} " ) (workspace does not contain the patched repository)"
68+ return
69+ fi
70+
4071 if patch --batch --forward -p1 -d " ${WORKSPACE_DIR} " --dry-run < " ${patch_file} " > /dev/null 2>&1 ; then
4172 echo " Applying $( basename " ${patch_file} " ) "
4273 patch --batch --forward -p1 -d " ${WORKSPACE_DIR} " < " ${patch_file} " > /dev/null
@@ -48,8 +79,7 @@ apply_patch_file() {
4879 return
4980 fi
5081
51- echo " Error: Failed to apply $( basename " ${patch_file} " ) in ${WORKSPACE_DIR} "
52- exit 1
82+ echo " Warning: Failed to apply $( basename " ${patch_file} " ) in ${WORKSPACE_DIR} " >&2
5383}
5484
5585shopt -s nullglob
You can’t perform that action at this time.
0 commit comments