Skip to content

Commit de3b2ca

Browse files
authored
Merge pull request #199 from sysprog21/skip-commit-hash
Skip commit hashes for spell check
2 parents 7d05741 + 377cced commit de3b2ca

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)