Skip to content

Commit a3d4a0b

Browse files
committed
Enforce American English in commit messages
This commit introduces a spell checker configured for American English. The commit-msg hook aborts the commit if aspell detects any words that do not conform to en_US spelling. Change-Id: Ibb36bcf01fc02c52187f66ad8f948e222068d238
1 parent 9e69c70 commit a3d4a0b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

scripts/aspell-pws

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,5 @@ tcp
298298
awk
299299
sed
300300
changeid
301+
en
302+
msg

scripts/commit-msg.hook

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,22 @@ validate_commit_message() {
322322
# 12. Avoid abusive language in commit message content
323323
# ------------------------------------------------------------------------------
324324

325-
FULL_COMMIT_MSG=$(sed '/^#/d;/^[[:space:]]*$/d' "$COMMIT_MSG_FILE")
325+
FULL_COMMIT_MSG=$(sed '/^#/d;/^[[:space:]]*$/d;/^[[:space:]]*Change-Id:/d' "$COMMIT_MSG_FILE")
326326
# Extended list of abusive words (case-insensitive).
327327
# Adjust the list as needed.
328328
ABUSIVE_WORDS_REGEX='\b(fuck|fucking|dick|shit|bitch|asshole|cunt|motherfucker|damn|crap|dumbass|piss)\b'
329329
if echo "$FULL_COMMIT_MSG" | grep -Eiq "$ABUSIVE_WORDS_REGEX"; then
330330
add_warning 1 "Commit message contains inappropriate language. Avoid using abusive words"
331331
fi
332+
333+
# 13. Always use American English.
334+
# ------------------------------------------------------------------------------
335+
336+
# Use aspell to list misspelled words according to American English.
337+
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
338+
if [ -n "$MISSPELLED_WORDS" ]; then
339+
add_warning 1 "Avoid using non-American English words"
340+
fi
332341
}
333342

334343
unset GREP_OPTIONS

0 commit comments

Comments
 (0)