@@ -268,25 +268,30 @@ validate_commit_message() {
268268 # 7. Ensure the commit subject has more than one word.
269269 # ------------------------------------------------------------------------------
270270
271- if [ " $( echo " $COMMIT_SUBJECT_TO_PROCESS " | wc -w) " -le 1 ]; then
271+ if [ " $( echo " ${ COMMIT_SUBJECT_TO_PROCESS} " | wc -w) " -le 1 ]; then
272272 add_warning 1 " Do not write single-word commits. Provide a descriptive subject"
273273 fi
274274
275275 # 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
277277 add_warning 1 " Avoid mentioning C source filenames in the commit subject"
278278 fi
279279
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+
280285 # 8. Use the body to explain what and why vs. how
281286 # ------------------------------------------------------------------------------
282287
283288 # 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)
285290
286291 # If the subject is oversimplified for a queue function OR queue.c is modified,
287292 # 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
290295 add_warning 1 " Commit message oversimplified. Use the commit message body to explain what and why."
291296 fi
292297
@@ -299,14 +304,14 @@ validate_commit_message() {
299304 # 10. Disallow backticks anywhere in the commit message.
300305 # ------------------------------------------------------------------------------
301306
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
303308 add_warning 1 " Avoid using backticks in commit messages"
304309 fi
305310
306311 # 11. Avoid commit subject that simply states a file update (e.g. "Update console.c")
307312 # ------------------------------------------------------------------------------
308313
309- if [[ $COMMIT_SUBJECT_TO_PROCESS =~ ^Update[[:space:]]+ ([^[:space:]]+)$ ]]; then
314+ if [[ ${ COMMIT_SUBJECT_TO_PROCESS} =~ ^Update[[:space:]]+ ([^[:space:]]+)$ ]]; then
310315 candidate=" ${BASH_REMATCH[1]} "
311316 # Only warn if the candidate filename ends with .c or .h
312317 if [[ $candidate =~ \. (c| h)$ ]]; then
0 commit comments