File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -260,8 +260,6 @@ validate_commit_message() {
260
260
# 7. Use the body to explain what and why vs. how
261
261
# ------------------------------------------------------------------------------
262
262
263
- # ?
264
-
265
263
# 8. Do no write single worded commits
266
264
# ------------------------------------------------------------------------------
267
265
@@ -278,6 +276,22 @@ validate_commit_message() {
278
276
279
277
[[ ${COMMIT_SUBJECT_TO_PROCESS} =~ ^[[:blank:]]+ ]]
280
278
test $? -eq 1 || add_warning 1 " Do not start the subject line with whitespace"
279
+
280
+ # 10. Avoid single word commit messages in subject
281
+ # ------------------------------------------------------------------------------
282
+
283
+ word_count=$( echo " $COMMIT_SUBJECT_TO_PROCESS " | wc -w)
284
+ test " $word_count " -gt 1
285
+ 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
281
295
}
282
296
283
297
unset GREP_OPTIONS
You can’t perform that action at this time.
0 commit comments