File tree Expand file tree Collapse file tree 4 files changed +35
-13
lines changed Expand file tree Collapse file tree 4 files changed +35
-13
lines changed Original file line number Diff line number Diff line change @@ -489,10 +489,29 @@ validate_commit_message() {
489
489
# ------------------------------------------------------------------------------
490
490
491
491
# Alert if the commit message appears to be written in Chinese.
492
- # This pattern matches any Chinese character (common CJK Unified Ideographs).
493
- MISSPELLED_WORDS=$( echo " $FULL_COMMIT_MSG " | LC_ALL=C grep " [一-龥]" )
494
- if [ -n " $MISSPELLED_WORDS " ]; then
495
- add_warning 1 " Commit message appears to be written in Chinese: $MISSPELLED_WORDS "
492
+ # This pattern matches Chinese CJK Unified Ideographs range.
493
+ # Use proper UTF-8 handling to avoid false positives with Unicode symbols like ✓ and ✗.
494
+ if command -v python3 > /dev/null 2>&1 ; then
495
+ CHINESE_TEXT=$( echo " $FULL_COMMIT_MSG " | python3 -c "
496
+ import sys, re
497
+ text = sys.stdin.read()
498
+ chinese_chars = re.findall(r'[\u4e00-\u9fff]', text)
499
+ if chinese_chars:
500
+ print(''.join(chinese_chars))
501
+ " )
502
+ else
503
+ # Fallback: Only detect actual Chinese character patterns if python3 is not available
504
+ CHINESE_TEXT=$( echo " $FULL_COMMIT_MSG " | grep -o " [一-龥]" 2> /dev/null || echo " " )
505
+ # Filter out false positives by checking if the detected text contains actual Chinese words
506
+ if [ -n " $CHINESE_TEXT " ] && ! echo " $CHINESE_TEXT " | grep -q " [✓✗]" ; then
507
+ CHINESE_TEXT=" $CHINESE_TEXT "
508
+ else
509
+ CHINESE_TEXT=" "
510
+ fi
511
+ fi
512
+
513
+ if [ -n " $CHINESE_TEXT " ]; then
514
+ add_warning 1 " Commit message appears to be written in Chinese: $CHINESE_TEXT "
496
515
fi
497
516
498
517
MSG_FOR_SPELLCHECK_LINE_FINDING=$( echo " $FULL_COMMIT_MSG_WITH_SPACE " | sed -E \
Original file line number Diff line number Diff line change 1
1
RED=" "
2
+ GREEN=" "
2
3
YELLOW=" "
3
4
BLUE=" "
4
5
WHITE=" "
@@ -11,6 +12,7 @@ set_colors() {
11
12
# If color is forced (always) or auto and we are on a tty, enable color.
12
13
if [[ " $default_color " == " always" ]] || [[ " $default_color " == " auto" && -t 1 ]]; then
13
14
RED=' \033[1;31m'
15
+ GREEN=' \033[1;32m'
14
16
YELLOW=' \033[1;33m'
15
17
BLUE=' \033[1;34m'
16
18
WHITE=' \033[1;37m'
Original file line number Diff line number Diff line change @@ -31,9 +31,9 @@ report_result() {
31
31
local status=" $1 "
32
32
local message=" $2 "
33
33
if [ " $status " -eq 0 ]; then
34
- printf " ${GREEN} ✓ ${NC} \n"
34
+ printf " [ ${GREEN} OK ${NC} ] \n"
35
35
else
36
- printf " ${RED} ✗ ${NC} \n"
36
+ printf " [ ${RED} FAIL ${NC} ] \n"
37
37
if [ -n " $message " ]; then
38
38
ERRORS_FOUND+=(" $message " )
39
39
fi
334
334
# Clear the progress line
335
335
printf " \r%*s\r" 50 " "
336
336
337
- # === SUMMARY ===
338
- printf " \n${CYAN} === Pre-commit Check Summary === ${NC} \n\n "
337
+ # Summary
338
+ printf " \n"
339
339
340
340
# Show file changes
341
341
printf " ${CYAN} Files to be committed:${NC} \n"
359
359
if [ ${# ERRORS_FOUND[@]} -gt 0 ]; then
360
360
printf " \n${RED} Errors found:${NC} \n"
361
361
for error in " ${ERRORS_FOUND[@]} " ; do
362
- printf " ${RED} ✗ ${NC} %s\n" " $error "
362
+ printf " [ ${RED} FAIL ${NC} ] %s\n" " $error "
363
363
done
364
364
fi
365
365
Original file line number Diff line number Diff line change @@ -64,17 +64,18 @@ run_build_checks() {
64
64
echo " "
65
65
66
66
# Clean previous build artifacts for fresh check
67
- echo -e " ${YELLOW} Cleaning previous build...${NC} "
67
+ printf " ${YELLOW} Cleaning previous build...${NC} "
68
68
make clean > /dev/null 2>&1 || true
69
+ printf " [ ${GREEN} OK${NC} ]\n"
69
70
70
- echo -e " ${YELLOW} Building project...${NC} "
71
+ printf " ${YELLOW} Building project...${NC} "
71
72
72
73
# Capture build output for better error reporting
73
74
build_output=$( make 2>&1 )
74
75
build_result=$?
75
76
76
77
if [ $build_result -ne 0 ]; then
77
- echo -e " ${RED} Build failed! ${NC} "
78
+ printf " [ ${RED} FAIL ${NC} ]\n "
78
79
echo " "
79
80
echo " Build output:"
80
81
echo " ============="
@@ -85,7 +86,7 @@ run_build_checks() {
85
86
return 1
86
87
fi
87
88
88
- echo -e " ${GREEN} ✓ Build successful ${NC} "
89
+ printf " [ ${GREEN} OK ${NC} ]\n "
89
90
90
91
# Additional checks could be added here
91
92
# For example: basic tests, format checks, etc.
You can’t perform that action at this time.
0 commit comments