Skip to content

Commit e4ad8ec

Browse files
committed
Avoid using just a filename like "Update qtest.c"
Each git commit message subject should be sufficiently descriptive, and the commit hook will alert students who fail to provide meaningful and detailed subjects. Change-Id: Iaddd15b1020bee3e3ea518145a99f617ca438ccd
1 parent 9de8c61 commit e4ad8ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/commit-msg.hook

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ validate_commit_message() {
283283
word_count=$(echo "$COMMIT_SUBJECT_TO_PROCESS" | wc -w)
284284
test "$word_count" -gt 1
285285
test $? -eq 0 || add_warning 1 "Commit subject should contain more than one word (e.g. 'Update dependencies' instead of 'Update')"
286+
287+
# 11. Avoid commit subject that simply states a file update (e.g. "Update console.c")
288+
if [[ $COMMIT_SUBJECT_TO_PROCESS =~ ^Update[[:space:]]+([^[:space:]]+)$ ]]; then
289+
candidate="${BASH_REMATCH[1]}"
290+
# Only warn if the candidate filename ends with .c or .h
291+
if [[ $candidate =~ \.(c|h)$ ]]; then
292+
add_warning 1 "Avoid using just a filename like '$candidate'. Provide a functional, meaningful description"
293+
fi
294+
fi
286295
}
287296

288297
unset GREP_OPTIONS

0 commit comments

Comments
 (0)