From 937305bc41000ea0091b8868564e6b19768927a8 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 5 Jan 2021 21:46:51 +0700 Subject: [PATCH] [ticket/16675] Restore commit message checks PHPBB3-16675 --- .github/workflows/tests.yml | 8 +++++--- git-tools/commit-msg-hook-range.sh | 12 +++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7a89b920cd..9bcbf41d1f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,6 +26,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 100 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -76,11 +78,11 @@ jobs: - name: Check commit message env: - BRANCH: ${{ github.event.pull_request.base.ref }} + BRANCH: ${{ github.event.pull_request.base.sha }} PR_SHA: ${{ github.event.pull_request.head.sha }} - if: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.base.ref != '' }} + if: github.event.pull_request.head.sha != '' && github.event.pull_request.base.sha != '' run: | - git remote set-branches --add origin $BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$BRANCH..$PR_SHA + git-tools/commit-msg-hook-range.sh $BRANCH..$PR_SHA # Tests for MySQL and MariaDB mysql-tests: diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh index 91f7577eb5..84f291b221 100755 --- a/git-tools/commit-msg-hook-range.sh +++ b/git-tools/commit-msg-hook-range.sh @@ -24,7 +24,17 @@ COMMIT_MSG_HOOK_FATAL=$(git config --bool phpbb.hooks.commit-msg.fatal 2> /dev/n git config phpbb.hooks.commit-msg.fatal true EXIT_STATUS=0 -for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE") + +COMMIT_HASHES=$(git rev-list --no-merges "$COMMIT_RANGE") + +# If any message have been returned instead of commit hashes list +# send a non-zero exit status upstream. +if ! [[ "$COMMIT_HASHES" =~ ^[0-9a-f]{5,40} ]] +then + EXIT_STATUS=1 +fi + +for COMMIT_HASH in $COMMIT_HASHES do echo "Inspecting commit message of commit $COMMIT_HASH"