Skip to content

Commit 1104f25

Browse files
committed
Take commit msg from SHA-1 to verify pr prefix; don't count Signed-Off-By
Commit fixes issues: - git body count characters "fits" for requirements when "Signed-Off-By" was set - take commit message from commit SHA-1 instead of compute it in the script in Github workflows Signed-off-by: Daniel Pawlik <[email protected]>
1 parent 815fcbf commit 1104f25

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.github/workflows/verify-pr-prefix.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23+
- name: Dump commit message to file
24+
run: |
25+
git fetch origin ${{ github.event.pull_request.head.sha }}
26+
git log -1 --pretty=format:"%B" ${{ github.event.pull_request.head.sha }} | head -n1 > commit-message-file
27+
2328
- name: Run commit message check
2429
id: prefixcheck
2530
run: |
26-
./scripts/check-role-prefix.sh
31+
./scripts/check-role-prefix.sh commit-message-file

scripts/check-role-prefix.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22

33
# Get the latest commit message file
4-
TMP_MSG_FILE=$(mktemp)
5-
git log -1 --pretty=format:"%s%n%n%b" >"$TMP_MSG_FILE"
4+
TMP_MSG_FILE="$1"
5+
6+
if [ -z "$TMP_MSG_FILE" ]; then
7+
TMP_MSG_FILE=$(mktemp)
8+
git log -1 --pretty=format:"%B" | head -n1
9+
fi
610

711
echo "Checking latest commit message:"
812
cat "$TMP_MSG_FILE"

scripts/git-check-commit-body-length.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FAIL_LENGTH=0
2020
FAIL_SIGNED_OFF_BY=0
2121

2222
BODY=$(tail -n +3 "$MSG_FILE" | sed '/^\s*#/d' | sed '/^\s*$/d')
23-
BODY_LEN=$(echo -n "$BODY" | wc -m)
23+
BODY_LEN=$(echo -n "$BODY" | sed '/Signed-off-by:/d' | wc -m)
2424

2525
if [ "$BODY_LEN" -lt "$MIN_BODY_LEN" ]; then
2626
echo -e "\n\n**WARNING: Commit message body is too short (has $BODY_LEN chars, minimum $MIN_BODY_LEN required).**\n" >&2

0 commit comments

Comments
 (0)