summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2020-06-11 10:42:13 -0700
committerDan Smith <dansmith@redhat.com>2020-06-15 11:15:31 -0700
commitaebc829c4e0d39a160eaaa5ad949c1256c8179e6 (patch)
tree31809b4dd6cc2b9e0ffa3ffe9c1671417b8b3a59 /tools
parenta9e0b0573da65074db686ceb0c5cc000ec7110f1 (diff)
downloadnova-aebc829c4e0d39a160eaaa5ad949c1256c8179e6.tar.gz
Check cherry-pick hashes in pep8 tox target
This adds a tools/ script that checks any cherry-picked hashes on the current commit (or a provided commit) to make sure that all the hashes exist on at least master or stable/.* branches. This should help avoid accidentally merging stable backports where one of the hashes along the line has changed due to conflicts. Change-Id: I4afaa0808b75cc31a8dd14663912c162281a1a42
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check-cherry-picks.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/check-cherry-picks.sh b/tools/check-cherry-picks.sh
new file mode 100755
index 0000000000..307837d2aa
--- /dev/null
+++ b/tools/check-cherry-picks.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# A tool to check the cherry-pick hashes from the current git commit message
+# to verify that they're all on either master or stable/ branches
+#
+
+hashes=$(git show --format='%b' --quiet $1 | sed -nr 's/^.cherry picked from commit (.*).$/\1/p')
+checked=0
+branches+=""
+for hash in $hashes; do
+ branch=$(git branch -a --contains "$hash" 2>/dev/null| grep -oE '(master|stable/[a-z]+)')
+ if [ $? -ne 0 ]; then
+ echo "Cherry pick hash $hash not on any master or stable branches"
+ exit 1
+ fi
+ branches+=" $branch"
+ checked=$(($checked + 1))
+done
+
+if [ $checked -eq 0 ]; then
+ if ! grep -q '^defaultbranch=stable/' .gitreview; then
+ echo "Checked $checked cherry-pick hashes: OK"
+ exit 0
+ else
+ if ! git show --format='%B' --quiet | grep -qi 'stable.*only'; then
+ echo 'Stable branch requires either cherry-pick -x headers or [stable-only] tag!'
+ exit 1
+ fi
+ fi
+else
+ echo Checked $checked cherry-pick hashes on branches: $(echo $branches | tr ' ' '\n' | sort | uniq)
+fi