tools: Allow check-cherry-picks.sh to be disabled by an env var

The checks performed by this script aren't always useful to downstream
consumers of the repo so allow them to disable the script without having
to make changes to tox.ini.

We use the $commit_hash variable for the check for stable-only patches,
else it will incorrectly fail because it is checking the merge patch's
commit message.

Change-Id: I553fdda626b8afb8949d5ae9fc170caf87d31032
This commit is contained in:
zhangbailin 2021-03-23 17:48:18 +08:00
parent 8cddcf81c7
commit 891c1de79a
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,11 @@
# to verify that they're all on either master or stable/ branches
#
# Allow this script to be disabled by a simple env var
if [ ${DISABLE_CHERRY_PICK_CHECK:-0} -eq 1 ]; then
exit 0
fi
commit_hash=""
# Check if the patch is a merge patch by counting the number of parents.
@ -32,7 +37,7 @@ if [ $checked -eq 0 ]; then
echo "Checked $checked cherry-pick hashes: OK"
exit 0
else
if ! git show --format='%B' --quiet | grep -qi 'stable.*only'; then
if ! git show --format='%B' --quiet $commit_hash | grep -qi 'stable.*only'; then
echo 'Stable branch requires either cherry-pick -x headers or [stable-only] tag!'
exit 1
fi