From 0770f780c7b1f823c9b5d6d1fd77eed7a9887cf5 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Sat, 22 Feb 2025 10:48:47 +0800 Subject: [PATCH] Provide more verbs for checking commit message The commit e4ad8ec was limited to the subject starting with "Update," and the checker captures additional verbs like "Fix" and "Improve." Change-Id: I8f155ec1a8a6277272cf32c541ada1d182b82501 --- scripts/commit-msg.hook | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/commit-msg.hook b/scripts/commit-msg.hook index ee2795cab..9b9ec3283 100755 --- a/scripts/commit-msg.hook +++ b/scripts/commit-msg.hook @@ -314,11 +314,11 @@ validate_commit_message() { # 11. Avoid commit subject that simply states a file update (e.g. "Update console.c") # ------------------------------------------------------------------------------ - if [[ ${COMMIT_SUBJECT_TO_PROCESS} =~ ^Update[[:space:]]+([^[:space:]]+)$ ]]; then - candidate="${BASH_REMATCH[1]}" + if [[ "$COMMIT_SUBJECT_TO_PROCESS" =~ ^(Update|Modify|Change|Fix|Refine|Improve|Revise)[[:space:]]+([^[:space:]]+)$ ]]; then + candidate="${BASH_REMATCH[2]}" # Only warn if the candidate filename ends with .c or .h - if [[ $candidate =~ \.(c|h)$ ]]; then - add_warning 1 "Avoid using just a filename like '$candidate'. Provide a functional, meaningful description" + if [[ "$candidate" =~ \.(c|h)$ ]]; then + add_warning 1 "Avoid using just a filename like '$candidate'. Provide a functional, meaningful description" fi fi