Skip to content

Commit 97134e2

Browse files
authored
Merge pull request #197 from sysprog21/avoid-chinese-messages
Avoid Chinese messages
2 parents 62aad34 + a1da15f commit 97134e2

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

scripts/aspell-pws

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,35 @@ sed
300300
changeid
301301
en
302302
msg
303+
cjk
304+
massif
305+
csapp
306+
cmu
307+
ele
308+
lima
309+
github
310+
ih
311+
it
312+
AddressSanitizer
313+
asan
314+
dbg
315+
dev
316+
dpkg
317+
apt
318+
siglongjmp
319+
sigsetjmp
320+
SIGABRT
321+
SIGALRM
322+
SIGBUS
323+
SIGFPE
324+
SIGHUP
325+
SIGILL
326+
SIGINT
327+
SIGKILL
328+
SIGPIPE
329+
SIGQUIT
330+
SIGSEGV
331+
SIGTERM
332+
SIGTRAP
333+
SIGUSR
334+
SIGWINCH

scripts/commit-msg.hook

Lines changed: 13 additions & 3 deletions
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,8 +334,18 @@ validate_commit_message() {
334334
# 13. Always use American English.
335335
# ------------------------------------------------------------------------------
336336

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)
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+
344+
# Remove quoted text from FULL_COMMIT_MSG for spell checking.
345+
MSG_FOR_SPELLCHECK=$(echo "$FULL_COMMIT_MSG" | sed -E "s/(['\"][^'\"]*['\"])//g")
346+
347+
# Use aspell to list misspelled words according to American English, ignoring quoted text.
348+
MISSPELLED_WORDS=$(echo "$MSG_FOR_SPELLCHECK" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
339349
if [ -n "$MISSPELLED_WORDS" ]; then
340350
add_warning 1 "Avoid using non-American English words"
341351
fi

0 commit comments

Comments
 (0)