
non-SLURP branches are EOL'd in case they reach their end of maintained phase. This could produce a situation when a patch is merged in a non-SLURP branch that was deleted in the meantime and it's further backports fail on gate with backport validator as the hash of the non-SLURP version of the patch is not on any branch. This patch fixes the above issue as follows: in case a hash is not found on any branch, then it checks if it can be found under any *-eol tag and only fails if there is not found either. Change-Id: I56705bce8ee4354cd5cb1577a520c2d1c525f57b
52 lines
1.8 KiB
Bash
Executable File
52 lines
1.8 KiB
Bash
Executable File
#!/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, stable/ or unmaintained/
|
|
# branches
|
|
#
|
|
|
|
commit_hash=""
|
|
|
|
# Check if the patch is a merge patch by counting the number of parents.
|
|
# If the patch has 2 parents, then the 2nd parent is the patch we want
|
|
# to validate.
|
|
parent_number=$(git show --format='%P' --quiet | awk '{print NF}')
|
|
if [ $parent_number -eq 2 ]; then
|
|
commit_hash=$(git show --format='%P' --quiet | awk '{print $NF}')
|
|
fi
|
|
|
|
if git show --format='%aE' --quiet $commit_hash | grep -qi 'infra-root@openstack.org'; then
|
|
echo 'Bot generated change; ignoring'
|
|
exit 0
|
|
fi
|
|
|
|
hashes=$(git show --format='%b' --quiet $commit_hash | 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-z0-9.]+|unmaintained/[a-z0-9.]+)')
|
|
if [ $? -ne 0 ]; then
|
|
branch=$(git tag --contains "$hash" 2>/dev/null| grep -oE '([0-9.]+-eol)')
|
|
if [ $? -ne 0 ]; then
|
|
echo "Cherry pick hash $hash not on any master, stable, unmaintained or EOL'd branches"
|
|
exit 1
|
|
fi
|
|
fi
|
|
branches+=" $branch"
|
|
checked=$(($checked + 1))
|
|
done
|
|
|
|
if [ $checked -eq 0 ]; then
|
|
if ! grep -qE '^defaultbranch=(stable|unmaintained)/' .gitreview; then
|
|
echo "Checked $checked cherry-pick hashes: OK"
|
|
exit 0
|
|
else
|
|
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
|
|
fi
|
|
else
|
|
echo Checked $checked cherry-pick hashes on branches: $(echo $branches | tr ' ' '\n' | sort | uniq)
|
|
fi
|