@@ -394,25 +394,24 @@ validate_commit_message() {
394
394
add_warning 1 " Do not write single-word commits. Provide a descriptive subject"
395
395
fi
396
396
397
- # 7a. Avoid using C source filenames as the commit subject.
397
+ # 7a. Avoid using C source filenames as the commit subject
398
398
if [[ " ${COMMIT_SUBJECT_TO_PROCESS} " =~ ^[_a-zA-Z0-9]+\. [ch]$ ]]; then
399
399
add_warning 1 " Avoid mentioning C source filenames in the commit subject"
400
400
fi
401
401
402
- # 7b. Disallow parentheses in the commit subject.
402
+ # 7b. Disallow parentheses in the commit subject
403
403
if [[ ${COMMIT_SUBJECT_TO_PROCESS} =~ [\(\) ] ]]; then
404
404
add_warning 1 " Avoid using parentheses '()' in commit subjects"
405
405
fi
406
406
407
- # 7c. Disallow conventional commit format (e.g., "chore(scope):", "feat:", etc.)
407
+ # 7c. Disallow conventional commit format
408
408
# These formats waste precious characters from the 50-character limit
409
409
# Check for patterns like "type:" or "type(scope):" with optional breaking change indicator
410
410
if [[ ${COMMIT_SUBJECT} =~ ^[a-z]+\( [^\) ]+\) :[[:space:]] ]] || [[ ${COMMIT_SUBJECT} =~ ^[a-z]+! ? :[[:space:]] ]]; then
411
411
add_warning 1 " Avoid conventional commit format (e.g., 'chore(scripts):', 'feat:', 'fix:'). Write a direct, descriptive subject"
412
412
fi
413
413
414
- # 7d. Alert if the commit subject starts with "Implementation"
415
- # ------------------------------------------------------------------------------
414
+ # 7d. Alert if the commit subject starts with non-imperative words
416
415
if [[ " ${COMMIT_SUBJECT_TO_PROCESS} " =~ ^(First| My| Implementation| Implementations| Creation| Modification| Queue) ]]; then
417
416
add_warning 1 " Commit subject should use imperative mood"
418
417
fi
@@ -439,6 +438,14 @@ validate_commit_message() {
439
438
fi
440
439
fi
441
440
441
+ # 8a. For queue functions (q_*), require detailed explanation in body
442
+ # Check if subject mentions queue functions like "Implement q_size" or "Fix q_new"
443
+ if [[ " ${COMMIT_SUBJECT} " =~ q_[a-zA-Z_]+ ]]; then
444
+ if [ " ${NON_COMMENT_COUNT} " -le 1 ]; then
445
+ add_warning 1 " Queue function commits require detailed explanation in the body"
446
+ fi
447
+ fi
448
+
442
449
# 9. Do not start the subject line with whitespace
443
450
# ------------------------------------------------------------------------------
444
451
@@ -496,12 +503,44 @@ validate_commit_message() {
496
503
497
504
# Use aspell to list misspelled words according to American English, ignoring quoted text.
498
505
MISSPELLED_WORDS=$( echo " $MSG_FOR_SPELLCHECK " | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
499
- if [ -n " $MISSPELLED_WORDS " ]; then
500
- results=$( get_all_match_positions " $MSG_FOR_SPELLCHECK_LINE_FINDING " " $MISSPELLED_WORDS " )
501
506
502
- while read -r result; do
503
- add_warning " ${result#*: } " " Avoid using non-American English words: ${result%%:* } "
504
- done <<< " $results"
507
+ # Filter out words that are filenames in the git repository
508
+ if [ -n " $MISSPELLED_WORDS " ]; then
509
+ # Get comprehensive list of repository-related words to exclude
510
+ # 1. Full filenames with extensions
511
+ # 2. Filenames without extensions
512
+ # 3. Directory names
513
+ # 4. File extensions without the dot
514
+ GIT_WORDS=$(
515
+ {
516
+ # Full filenames
517
+ git ls-files 2> /dev/null | xargs -n1 basename 2> /dev/null
518
+ # Filenames without extensions
519
+ git ls-files 2> /dev/null | xargs -n1 basename 2> /dev/null | sed ' s/\.[^.]*$//'
520
+ # Directory names
521
+ git ls-files 2> /dev/null | xargs -n1 dirname 2> /dev/null | tr ' /' ' \n' | grep -v ' ^\.$'
522
+ # File extensions (without dot)
523
+ git ls-files 2> /dev/null | grep ' \.' | sed ' s/.*\.//'
524
+ } | sort -u
525
+ )
526
+ # Filter out repository filenames from misspelled words
527
+ FILTERED_MISSPELLED=" "
528
+ while IFS= read -r word; do
529
+ # Check if the word matches any filename or file component
530
+ if ! echo " $GIT_WORDS " | grep -qxFi " $word " ; then
531
+ FILTERED_MISSPELLED=" $FILTERED_MISSPELLED$word " $' \n '
532
+ fi
533
+ done <<< " $MISSPELLED_WORDS"
534
+
535
+ # Remove trailing newline
536
+ FILTERED_MISSPELLED=" ${FILTERED_MISSPELLED% $' \n ' } "
537
+ if [ -n " $FILTERED_MISSPELLED " ]; then
538
+ results=$( get_all_match_positions " $MSG_FOR_SPELLCHECK_LINE_FINDING " " $FILTERED_MISSPELLED " )
539
+
540
+ while read -r result; do
541
+ add_warning " ${result#*: } " " Avoid using non-American English words: ${result%%:* } "
542
+ done <<< " $results"
543
+ fi
505
544
fi
506
545
}
507
546
0 commit comments