Skip to content

Commit 62aad34

Browse files
authored
Merge pull request #196 from sysprog21/enforce-english-commit
Enforce english commit
2 parents 9e69c70 + bb2d2be commit 62aad34

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,23 @@ 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" | \
326+
sed -E "s@${URL_REGEX#^}@@g")
326327
# Extended list of abusive words (case-insensitive).
327328
# Adjust the list as needed.
328329
ABUSIVE_WORDS_REGEX='\b(fuck|fucking|dick|shit|bitch|asshole|cunt|motherfucker|damn|crap|dumbass|piss)\b'
329330
if echo "$FULL_COMMIT_MSG" | grep -Eiq "$ABUSIVE_WORDS_REGEX"; then
330331
add_warning 1 "Commit message contains inappropriate language. Avoid using abusive words"
331332
fi
333+
334+
# 13. Always use American English.
335+
# ------------------------------------------------------------------------------
336+
337+
# Use aspell to list misspelled words according to American English.
338+
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
339+
if [ -n "$MISSPELLED_WORDS" ]; then
340+
add_warning 1 "Avoid using non-American English words"
341+
fi
332342
}
333343

334344
unset GREP_OPTIONS

0 commit comments

Comments
 (0)