@@ -268,25 +268,30 @@ validate_commit_message() {
268
268
# 7. Ensure the commit subject has more than one word.
269
269
# ------------------------------------------------------------------------------
270
270
271
- if [ " $( echo " $COMMIT_SUBJECT_TO_PROCESS " | wc -w) " -le 1 ]; then
271
+ if [ " $( echo " ${ COMMIT_SUBJECT_TO_PROCESS} " | wc -w) " -le 1 ]; then
272
272
add_warning 1 " Do not write single-word commits. Provide a descriptive subject"
273
273
fi
274
274
275
275
# 7a. Avoid using C source filenames as the commit subject.
276
- if [[ " $COMMIT_SUBJECT_TO_PROCESS " =~ ^[_a-zA-Z0-9]+\. [ch]$ ]]; then
276
+ if [[ " ${ COMMIT_SUBJECT_TO_PROCESS} " =~ ^[_a-zA-Z0-9]+\. [ch]$ ]]; then
277
277
add_warning 1 " Avoid mentioning C source filenames in the commit subject"
278
278
fi
279
279
280
+ # 11a. Disallow parentheses in the commit subject.
281
+ if [[ ${COMMIT_SUBJECT_TO_PROCESS} =~ [\(\) ] ]]; then
282
+ add_warning 1 " Avoid using parentheses '()' in commit subjects"
283
+ fi
284
+
280
285
# 8. Use the body to explain what and why vs. how
281
286
# ------------------------------------------------------------------------------
282
287
283
288
# Count non-comment, non-blank lines excluding "Change-Id:".
284
- NON_COMMENT_COUNT=$( sed ' /^[[:space:]]*#/d;/^[[:space:]]*$/d;/^[[:space:]]*Change-Id:/d' " $COMMIT_MSG_FILE " | wc -l | xargs)
289
+ NON_COMMENT_COUNT=$( sed ' /^[[:space:]]*#/d;/^[[:space:]]*$/d;/^[[:space:]]*Change-Id:/d' " ${ COMMIT_MSG_FILE} " | wc -l | xargs)
285
290
286
291
# If the subject is oversimplified for a queue function OR queue.c is modified,
287
292
# and there is only one meaningful line, issue a warning.
288
- if { [[ " $COMMIT_SUBJECT_TO_PROCESS " =~ ^(Implement| Finish)[[:space:]]+q_[[:alnum:]_]+\( ? \) ? $ ]] || \
289
- git diff --cached --name-only | grep -Eq ' (^|/)queue\.c$' ; } && [ " $NON_COMMENT_COUNT " -le 1 ]; then
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
290
295
add_warning 1 " Commit message oversimplified. Use the commit message body to explain what and why."
291
296
fi
292
297
@@ -299,14 +304,14 @@ validate_commit_message() {
299
304
# 10. Disallow backticks anywhere in the commit message.
300
305
# ------------------------------------------------------------------------------
301
306
302
- if sed ' /^[[:space:]]*#/d;/^[[:space:]]*$/d' " $COMMIT_MSG_FILE " | grep -q " \` " ; then
307
+ if sed ' /^[[:space:]]*#/d;/^[[:space:]]*$/d' " ${ COMMIT_MSG_FILE} " | grep -q " \` " ; then
303
308
add_warning 1 " Avoid using backticks in commit messages"
304
309
fi
305
310
306
311
# 11. Avoid commit subject that simply states a file update (e.g. "Update console.c")
307
312
# ------------------------------------------------------------------------------
308
313
309
- if [[ $COMMIT_SUBJECT_TO_PROCESS =~ ^Update[[:space:]]+ ([^[:space:]]+)$ ]]; then
314
+ if [[ ${ COMMIT_SUBJECT_TO_PROCESS} =~ ^Update[[:space:]]+ ([^[:space:]]+)$ ]]; then
310
315
candidate=" ${BASH_REMATCH[1]} "
311
316
# Only warn if the candidate filename ends with .c or .h
312
317
if [[ $candidate =~ \. (c| h)$ ]]; then
0 commit comments