Skip to content

Commit 9de8c61

Browse files
committed
Avoid single worded commits
Change-Id: I7b5be0a71c065300daef9988e4a06ab27f6e387f
1 parent 2edaad9 commit 9de8c61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/commit-msg.hook

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ validate_commit_message() {
260260
# 7. Use the body to explain what and why vs. how
261261
# ------------------------------------------------------------------------------
262262

263-
# ?
264-
265263
# 8. Do no write single worded commits
266264
# ------------------------------------------------------------------------------
267265

@@ -278,6 +276,13 @@ validate_commit_message() {
278276

279277
[[ ${COMMIT_SUBJECT_TO_PROCESS} =~ ^[[:blank:]]+ ]]
280278
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')"
281286
}
282287

283288
unset GREP_OPTIONS

0 commit comments

Comments
 (0)