2 # Find alleged cherry-picks
6 if [ $# != "2" ] ; then
7 echo "usage: check-cherry-picks.sh base_rev head_rev"
11 PICKABLE_BRANCHES
=${PICKABLE_BRANCHES:-master staging release-??.?? staging-??.??}
14 while read new_commit_sha
; do
15 if [ -z "$new_commit_sha" ] ; then
16 continue # skip empty lines
18 if [ "$GITHUB_ACTIONS" = 'true' ] ; then
19 echo "::group::Commit $new_commit_sha"
21 echo "================================================="
23 git rev-list
--max-count=1 --format=medium
"$new_commit_sha"
24 echo "-------------------------------------------------"
26 original_commit_sha
=$
(
27 git rev-list
--max-count=1 --format=format
:%B
"$new_commit_sha" \
28 |
grep -Ei -m1 "cherry.*[0-9a-f]{40}" \
29 |
grep -Eoi -m1 '[0-9a-f]{40}'
31 if [ "$?" != "0" ] ; then
32 echo " ? Couldn't locate original commit hash in message"
33 [ "$GITHUB_ACTIONS" = 'true' ] && echo ::endgroup
::
37 set -f # prevent pathname expansion of patterns
38 for branch_pattern
in $PICKABLE_BRANCHES ; do
39 set +f
# re-enable pathname expansion
41 while read -r picked_branch
; do
42 if git merge-base
--is-ancestor "$original_commit_sha" "$picked_branch" ; then
43 echo " ✔ $original_commit_sha present in branch $picked_branch"
45 range_diff_common
='git range-diff
48 '"$original_commit_sha~..$original_commit_sha"'
49 '"$new_commit_sha~..$new_commit_sha"'
52 if $range_diff_common --no-color |
grep -E '^ {4}[+-]{2}' > /dev
/null
; then
53 if [ "$GITHUB_ACTIONS" = 'true' ] ; then
55 echo -n "::warning ::"
59 echo "Difference between $new_commit_sha and original $original_commit_sha may warrant inspection:"
61 $range_diff_common --color
63 echo "Note this should not necessarily be treated as a hard fail, but a reviewer's attention should" \
64 "be drawn to it and github actions have no way of doing that but to raise a 'failure'"
67 echo " ✔ $original_commit_sha highly similar to $new_commit_sha"
68 $range_diff_common --color
69 [ "$GITHUB_ACTIONS" = 'true' ] && echo ::endgroup
::
72 # move on to next commit
77 --format="%(refname
)" \
78 "refs
/remotes
/origin
/$branch_pattern"
82 if [ "$GITHUB_ACTIONS" = 'true' ] ; then
88 echo "$original_commit_sha not found in any pickable branch"
93 -E -i --grep="cherry.
*[0-9a-f]{40}" --reverse \