@@ -251,19 +251,31 @@ validate_commit_message() {
251
251
252
252
URL_REGEX=' ^[[:blank:]]*(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]'
253
253
254
- # Ensure the commit message lines are loaded into an array.
255
- readarray -t COMMIT_MSG_LINES < " $COMMIT_MSG_FILE "
256
-
257
- for i in " ${! COMMIT_MSG_LINES[@]} " ; do
258
- LINE=" ${COMMIT_MSG_LINES[$i]} "
259
- # Trim leading and trailing whitespace.
260
- TRIMMED_LINE=" ${LINE# " ${LINE%% [![:space:]]* } " } "
261
- TRIMMED_LINE=" ${TRIMMED_LINE% " ${TRIMMED_LINE##* [![:space:]]} " } "
262
- LINE_NUMBER=$(( i+ 1 ))
263
- if [ " ${# TRIMMED_LINE} " -gt 72 ] && ! [[ " $TRIMMED_LINE " =~ $URL_REGEX ]]; then
264
- add_warning " $LINE_NUMBER " " Wrap the body at 72 characters (${# TRIMMED_LINE} chars)"
265
- fi
266
- done
254
+ # Ensure the commit message lines are loaded into an array.
255
+ readarray -t COMMIT_MSG_LINES < " $COMMIT_MSG_FILE "
256
+
257
+ for i in " ${! COMMIT_MSG_LINES[@]} " ; do
258
+ # Skip the first line (the subject) because the limit applies to the body.
259
+ if [ " $i " -eq 0 ]; then
260
+ continue
261
+ fi
262
+
263
+ LINE=" ${COMMIT_MSG_LINES[$i]} "
264
+
265
+ # Skip the line if it is a comment.
266
+ if [[ " $LINE " =~ ^[[:space:]]* # ]]; then
267
+ continue
268
+ fi
269
+
270
+ # Trim leading and trailing whitespace.
271
+ TRIMMED_LINE= " ${LINE# " ${LINE%% [![:space:]]* } " } "
272
+ TRIMMED_LINE= " ${TRIMMED_LINE% " ${TRIMMED_LINE##* [![:space:]]} " } "
273
+ LINE_NUMBER= $(( i+ 1 ))
274
+
275
+ if [ " ${# TRIMMED_LINE} " -gt 72 ] && ! [[ " $TRIMMED_LINE " =~ $URL_REGEX ]]; then
276
+ add_warning " $LINE_NUMBER " " Wrap the body at 72 characters (${# TRIMMED_LINE} chars)"
277
+ fi
278
+ done
267
279
268
280
# 7. Ensure the commit subject has more than one word.
269
281
# ------------------------------------------------------------------------------
@@ -282,6 +294,12 @@ validate_commit_message() {
282
294
add_warning 1 " Avoid using parentheses '()' in commit subjects"
283
295
fi
284
296
297
+ # 7c. Alert if the commit subject starts with "Implementation"
298
+ # ------------------------------------------------------------------------------
299
+ if [[ " ${COMMIT_SUBJECT_TO_PROCESS} " =~ ^(First| My| Implementation| Creation| Modification) ]]; then
300
+ add_warning 1 " Commit subject should use imperative mood"
301
+ fi
302
+
285
303
# 8. Use the body to explain what and why vs. how
286
304
# ------------------------------------------------------------------------------
287
305
0 commit comments