Skip to content

Commit 377cced

Browse files
committed
Skip commit hashes for spell check
The commit 4b1025c enforces American English in commit messages, but the spell checker might get confused with git commit hashes. Now, the hook looks for the word commit followed by a space and a Git hash of 7-40 hex characters. It replaces this entire pattern with the word commit. Change-Id: Ie718004a70dd27c0a64ac8af531395bd3d6fd6e1
1 parent 7d05741 commit 377cced

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/commit-msg.hook

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ validate_commit_message() {
344344
add_warning 1 "Commit message appears to be written in Chinese: $MISSPELLED_WORDS"
345345
fi
346346

347-
# Remove quoted text from FULL_COMMIT_MSG for spell checking.
348-
MSG_FOR_SPELLCHECK=$(echo "$FULL_COMMIT_MSG" | sed -E "s/(['\"][^'\"]*['\"])//g")
347+
# Remove quoted text and commit hashes from $FULL_COMMIT_MSG for spell checking.
348+
# Handles commit references like "commit 7d05741" (short) or full 40-char hashes.
349+
MSG_FOR_SPELLCHECK=$(echo "$FULL_COMMIT_MSG" | sed -E \
350+
-e "s/(['\"][^'\"]*['\"])//g" \
351+
-e "s/\bcommit[[:space:]]+[0-9a-fA-F]{7,40}\b/commit/g")
349352

350353
# Use aspell to list misspelled words according to American English, ignoring quoted text.
351354
MISSPELLED_WORDS=$(echo "$MSG_FOR_SPELLCHECK" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)

0 commit comments

Comments
 (0)