checkpatch: fix "checkpatch-feature-branch.sh" for master branch

The main purpose of "checkpatch-feature-branch.sh" is to test all
patches of a feature branch. When we run the script against master
(or nm-1-*), then there is no feature branch.

Previously, the script would just error out.

That is not very useful, in particular as we call this from gitlab-ci,
which also runs on master.

Instead, in that case, test the HEAD.
This commit is contained in:
Thomas Haller
2018-10-22 13:35:20 +02:00
parent 31f13acdc9
commit 4543785438

View File

@@ -17,7 +17,11 @@ RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#
REFS=( $(git log --reverse --format='%H' "${RANGES[@]}") )
[ "${#REFS[@]}" != 0 ] || die "no refs detected (HEAD is $(git rev-parse HEAD))"
if [ "${#REFS[@]}" == 0 ] ; then
# no refs detected. This means, $HEAD is already on master (or one of the
# stable nm-1-* branches. Just check the patch itself.
REFS=( $HEAD )
fi
SUCCESS=0
for H in ${REFS[@]}; do