From 61bbff410640f0565aed5a9a439501c55322ceb8 Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Tue, 4 Jun 2024 09:56:03 +0200 Subject: [PATCH] [KNI] fix commit check The env var `COMMITS` may be empty. Handle it accordingly. Signed-off-by: Francesco Romani (cherry picked from commit 68af65c2e0bb2c7e71b3e34bf7a43e75febd6b6a) --- hack-kni/verify-commits.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hack-kni/verify-commits.sh b/hack-kni/verify-commits.sh index 8b29049c6..7304b9e7b 100755 --- a/hack-kni/verify-commits.sh +++ b/hack-kni/verify-commits.sh @@ -3,9 +3,9 @@ set -e -o pipefail function finish { - if [ -f "$commit_msg_filename" ]; then - rm -f "$commit_msg_filename" - fi + if [ -f "$commit_msg_filename" ]; then + rm -f "$commit_msg_filename" + fi } trap finish EXIT @@ -17,9 +17,9 @@ if [[ "$TRIGGER_BRANCH" == resync-* ]]; then exit 0 fi -if (( $COMMITS <= 0 )); then - echo "WARN: no changes detected" - exit 0 +if [ -z "$COMMITS" ] || (( $COMMITS <= 0 )); then + echo "WARN: no changes detected [COMMITS=${COMMITS}]" + exit 0 fi echo "considering ${COMMITS} commits in PR whose head is $TRIGGER_BRANCH (into $UPSTREAM_BRANCH):"