Skip to content

Commit cacb312

Browse files
committed
Enforce queue function commit body requirement
commit-msg hook now validates that commits mentioning queue functions (q_*) must include detailed explanations in the message body, as required by contributing guide. Change-Id: Idec84de41a8b072310f57c07471b6913cc05adbf
1 parent 041fcbb commit cacb312

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/commit-msg.hook

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,25 +394,24 @@ validate_commit_message() {
394394
add_warning 1 "Do not write single-word commits. Provide a descriptive subject"
395395
fi
396396

397-
# 7a. Avoid using C source filenames as the commit subject.
397+
# 7a. Avoid using C source filenames as the commit subject
398398
if [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^[_a-zA-Z0-9]+\.[ch]$ ]]; then
399399
add_warning 1 "Avoid mentioning C source filenames in the commit subject"
400400
fi
401401

402-
# 7b. Disallow parentheses in the commit subject.
402+
# 7b. Disallow parentheses in the commit subject
403403
if [[ ${COMMIT_SUBJECT_TO_PROCESS} =~ [\(\)] ]]; then
404404
add_warning 1 "Avoid using parentheses '()' in commit subjects"
405405
fi
406406

407-
# 7c. Disallow conventional commit format (e.g., "chore(scope):", "feat:", etc.)
407+
# 7c. Disallow conventional commit format
408408
# These formats waste precious characters from the 50-character limit
409409
# Check for patterns like "type:" or "type(scope):" with optional breaking change indicator
410410
if [[ ${COMMIT_SUBJECT} =~ ^[a-z]+\([^\)]+\):[[:space:]] ]] || [[ ${COMMIT_SUBJECT} =~ ^[a-z]+!?:[[:space:]] ]]; then
411411
add_warning 1 "Avoid conventional commit format (e.g., 'chore(scripts):', 'feat:', 'fix:'). Write a direct, descriptive subject"
412412
fi
413413

414-
# 7d. Alert if the commit subject starts with "Implementation"
415-
# ------------------------------------------------------------------------------
414+
# 7d. Alert if the commit subject starts with non-imperative words
416415
if [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^(First|My|Implementation|Implementations|Creation|Modification|Queue) ]]; then
417416
add_warning 1 "Commit subject should use imperative mood"
418417
fi
@@ -439,6 +438,14 @@ validate_commit_message() {
439438
fi
440439
fi
441440

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+
442449
# 9. Do not start the subject line with whitespace
443450
# ------------------------------------------------------------------------------
444451

0 commit comments

Comments
 (0)