From 3781100b8cc570ca71a688d0ec5c28dda3244cdb Mon Sep 17 00:00:00 2001 From: Lumynous Date: Fri, 18 Apr 2025 15:12:42 +0800 Subject: [PATCH 1/2] Fix line counting of commit message hook The parenthesis was accidentally deleted in the previous commit. Change-Id: I8938e339057335d1604f535d3695ffd242bb8e92 --- scripts/commit-msg.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/commit-msg.hook b/scripts/commit-msg.hook index 89acbd546..443630ed4 100755 --- a/scripts/commit-msg.hook +++ b/scripts/commit-msg.hook @@ -208,7 +208,7 @@ build_commit_trailer_regex() { TRAILER_REGEX+="$each|" done # Remove the trailing pipe, then add a separator and blank space pattern. - TRAILER_REGEX="${TRAILER_REGEX%|})[$separators][[:blank:]]*" + TRAILER_REGEX="${TRAILER_REGEX%|})[$separators][[:blank:]]*)" fi # Append standalone trailer keys. From 7ffda90751a7889a9a80a71e684f5094ca8f063e Mon Sep 17 00:00:00 2001 From: Lumynous Date: Fri, 18 Apr 2025 15:55:37 +0800 Subject: [PATCH 2/2] Fix ignoring indented lines in commit messages Change-Id: If974372abff9cd3648a11c23667e35858a2706aa --- scripts/commit-msg.hook | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/commit-msg.hook b/scripts/commit-msg.hook index 443630ed4..94420a401 100755 --- a/scripts/commit-msg.hook +++ b/scripts/commit-msg.hook @@ -86,7 +86,7 @@ read_commit_message() { shopt -u extglob # ignore comments and indented lines - [[ $REPLY =~ ^(#|[ ][ ]) ]] + [[ $REPLY =~ ^(#| ) ]] test $? -eq 0 || COMMIT_MSG_LINES+=("$REPLY") [[ $REPLY =~ "# ------------------------ >8 ------------------------" ]] @@ -483,7 +483,8 @@ validate_commit_message() { MSG_FOR_SPELLCHECK_LINE_FINDING=$(echo "$FULL_COMMIT_MSG_WITH_SPACE" | sed -E \ -e "s/(['\"][^'\"]*['\"])//g" \ - -e "s/\bcommit[[:space:]]+[0-9a-fA-F]{7,40}\b/commit/g") + -e "s/\bcommit[[:space:]]+[0-9a-fA-F]{7,40}\b/commit/g" \ + -e "/^ /d") MSG_FOR_SPELLCHECK=$(echo "$MSG_FOR_SPELLCHECK_LINE_FINDING" | sed '/^[[:space:]]*$/d') # Use aspell to list misspelled words according to American English, ignoring quoted text.