diff --git a/scripts/aspell-pws b/scripts/aspell-pws index dedd4fa4e..00d2a452b 100644 --- a/scripts/aspell-pws +++ b/scripts/aspell-pws @@ -298,3 +298,5 @@ tcp awk sed changeid +en +msg diff --git a/scripts/commit-msg.hook b/scripts/commit-msg.hook index 62a99eb3d..d542d0bea 100755 --- a/scripts/commit-msg.hook +++ b/scripts/commit-msg.hook @@ -322,13 +322,23 @@ validate_commit_message() { # 12. Avoid abusive language in commit message content # ------------------------------------------------------------------------------ - FULL_COMMIT_MSG=$(sed '/^#/d;/^[[:space:]]*$/d' "$COMMIT_MSG_FILE") + FULL_COMMIT_MSG=$(sed '/^#/d;/^[[:space:]]*$/d;/^[[:space:]]*Change-Id:/d' "$COMMIT_MSG_FILE" | \ + sed -E "s@${URL_REGEX#^}@@g") # Extended list of abusive words (case-insensitive). # Adjust the list as needed. ABUSIVE_WORDS_REGEX='\b(fuck|fucking|dick|shit|bitch|asshole|cunt|motherfucker|damn|crap|dumbass|piss)\b' if echo "$FULL_COMMIT_MSG" | grep -Eiq "$ABUSIVE_WORDS_REGEX"; then add_warning 1 "Commit message contains inappropriate language. Avoid using abusive words" fi + + # 13. Always use American English. + # ------------------------------------------------------------------------------ + + # Use aspell to list misspelled words according to American English. + MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws) + if [ -n "$MISSPELLED_WORDS" ]; then + add_warning 1 "Avoid using non-American English words" + fi } unset GREP_OPTIONS