From 4543785438c5859799e9c68b80e63e30be5df82e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Oct 2018 13:35:20 +0200 Subject: [PATCH] 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. --- contrib/scripts/checkpatch-feature-branch.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh index 6741317be..2e0b58919 100755 --- a/contrib/scripts/checkpatch-feature-branch.sh +++ b/contrib/scripts/checkpatch-feature-branch.sh @@ -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