Skip to content

Commit dc3acf3

Browse files
committed
Avoid using generic subjects
Generic subjects like "Complete," "Finish," or "Done" are problematic because they: 1. Lack specificity, making it unclear what was actually changed. 2. Are ambiguous and provide poor historical context. 3. Assume finality, whereas in engineering practice, designs are always subject to further refinement or improvement. Change-Id: I8c27d25c9844d70618ce166579bee2cd3ef7c93d
1 parent 97134e2 commit dc3acf3

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)