Skip to content

Commit 47116c9

Browse files
authored
Merge pull request #198 from sysprog21/commit-more-explanation
Avoid using generic subjects
2 parents 97134e2 + dc3acf3 commit 47116c9

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* cppcheck-suppress nullPointer
1111
*/
1212

13-
13+
/* Change */
1414
/* Create an empty queue */
1515
struct list_head *q_new()
1616
{

scripts/commit-msg.hook

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,14 @@ validate_commit_message() {
288288
# Count non-comment, non-blank lines excluding "Change-Id:".
289289
NON_COMMENT_COUNT=$(sed '/^[[:space:]]*#/d;/^[[:space:]]*$/d;/^[[:space:]]*Change-Id:/d' "${COMMIT_MSG_FILE}" | wc -l | xargs)
290290

291-
# If the subject is oversimplified for a queue function OR queue.c is modified,
292-
# and there is only one meaningful line, issue a warning.
293-
if { [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^(Implement|Finish|Complete)[[:space:]]+q_[[:alnum:]_]+\(?\)?$ ]] || \
294-
git diff --cached --name-only | grep -Eq '(^|/)queue\.c$'; } && [ "${NON_COMMENT_COUNT}" -le 1 ]; then
295-
add_warning 1 "Commit message oversimplified. Use the commit message body to explain what and why."
291+
# If queue.c is modified and the commit message is oversimplified, forbid generic subjects.
292+
if git diff --cached --name-only | grep -Eq '(^|/)queue\.c$'; then
293+
if [ "${NON_COMMENT_COUNT}" -le 1 ]; then
294+
add_warning 1 "Commit message oversimplified. Use the commit message body to explain what and why."
295+
fi
296+
if [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^(Complete|Finish|Done)[[:space:]]+ ]]; then
297+
add_warning 1 "Avoid using generic subjects starting with 'Complete', 'Finish', or 'Done'"
298+
fi
296299
fi
297300

298301
# 9. Do not start the subject line with whitespace

0 commit comments

Comments
 (0)