diff --git a/.github/workflows/verify-pr-prefix.yml b/.github/workflows/verify-pr-prefix.yml index d446b1ddb2..fc47fd2375 100644 --- a/.github/workflows/verify-pr-prefix.yml +++ b/.github/workflows/verify-pr-prefix.yml @@ -20,7 +20,12 @@ jobs: with: fetch-depth: 0 + - name: Dump commit message to file + run: | + git fetch origin ${{ github.event.pull_request.head.sha }} + git log -1 --pretty=format:"%B" ${{ github.event.pull_request.head.sha }} | head -n1 > commit-message-file + - name: Run commit message check id: prefixcheck run: | - ./scripts/check-role-prefix.sh + ./scripts/check-role-prefix.sh commit-message-file diff --git a/scripts/check-role-prefix.sh b/scripts/check-role-prefix.sh index 73e5a8dea3..6ee3ba7229 100755 --- a/scripts/check-role-prefix.sh +++ b/scripts/check-role-prefix.sh @@ -1,8 +1,12 @@ #!/bin/bash # Get the latest commit message file -TMP_MSG_FILE=$(mktemp) -git log -1 --pretty=format:"%s%n%n%b" >"$TMP_MSG_FILE" +TMP_MSG_FILE="$1" + +if [ -z "$TMP_MSG_FILE" ]; then + TMP_MSG_FILE=$(mktemp) + git log -1 --pretty=format:"%B" | head -n1 +fi echo "Checking latest commit message:" cat "$TMP_MSG_FILE" diff --git a/scripts/git-check-commit-body-length.sh b/scripts/git-check-commit-body-length.sh index 2ce9e64ea9..656806a9a1 100755 --- a/scripts/git-check-commit-body-length.sh +++ b/scripts/git-check-commit-body-length.sh @@ -20,7 +20,7 @@ FAIL_LENGTH=0 FAIL_SIGNED_OFF_BY=0 BODY=$(tail -n +3 "$MSG_FILE" | sed '/^\s*#/d' | sed '/^\s*$/d') -BODY_LEN=$(echo -n "$BODY" | wc -m) +BODY_LEN=$(echo -n "$BODY" | sed '/Signed-off-by:/d' | wc -m) if [ "$BODY_LEN" -lt "$MIN_BODY_LEN" ]; then echo -e "\n\n**WARNING: Commit message body is too short (has $BODY_LEN chars, minimum $MIN_BODY_LEN required).**\n" >&2