Skip to content

Commit 208ea8e

Browse files
committed
Alert if the commit message is written in Chinese
The hook checks for the presence of characters in the typical Chinese Unicode range (e.g., CJK Unified Ideographs). Change-Id: I186bfd3ffd79868ddb1f51b4052fa4397fe19be5
1 parent 62aad34 commit 208ea8e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

scripts/aspell-pws

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,4 @@ sed
300300
changeid
301301
en
302302
msg
303+
cjk

scripts/commit-msg.hook

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ validate_commit_message() {
277277
add_warning 1 "Avoid mentioning C source filenames in the commit subject"
278278
fi
279279

280-
# 11a. Disallow parentheses in the commit subject.
280+
# 7b. Disallow parentheses in the commit subject.
281281
if [[ ${COMMIT_SUBJECT_TO_PROCESS} =~ [\(\)] ]]; then
282282
add_warning 1 "Avoid using parentheses '()' in commit subjects"
283283
fi
@@ -334,6 +334,13 @@ validate_commit_message() {
334334
# 13. Always use American English.
335335
# ------------------------------------------------------------------------------
336336

337+
# Alert if the commit message appears to be written in Chinese.
338+
# This pattern matches any Chinese character (common CJK Unified Ideographs).
339+
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | grep "[一-龥]")
340+
if [ -n "$MISSPELLED_WORDS" ]; then
341+
add_warning 1 "Commit message appears to be written in Chinese: $MISSPELLED_WORDS"
342+
fi
343+
337344
# Use aspell to list misspelled words according to American English.
338345
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
339346
if [ -n "$MISSPELLED_WORDS" ]; then

0 commit comments

Comments
 (0)