File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -282,16 +282,29 @@ validate_commit_message() {
282282
283283 word_count=$( echo " $COMMIT_SUBJECT_TO_PROCESS " | wc -w)
284284 test " $word_count " -gt 1
285- test $? -eq 0 || add_warning 1 " Commit subject should contain more than one word (e.g. 'Update dependencies' instead of 'Update') "
285+ test $? -eq 0 || add_warning 1 " Commit subject should contain more than one word. Summarize your changes "
286286
287287 # 11. Avoid commit subject that simply states a file update (e.g. "Update console.c")
288+ # ------------------------------------------------------------------------------
289+
288290 if [[ $COMMIT_SUBJECT_TO_PROCESS =~ ^Update[[:space:]]+ ([^[:space:]]+)$ ]]; then
289291 candidate=" ${BASH_REMATCH[1]} "
290292 # Only warn if the candidate filename ends with .c or .h
291293 if [[ $candidate =~ \. (c| h)$ ]]; then
292294 add_warning 1 " Avoid using just a filename like '$candidate '. Provide a functional, meaningful description"
293295 fi
294296 fi
297+
298+ # 12. Avoid abusive language in commit message content
299+ # ------------------------------------------------------------------------------
300+
301+ FULL_COMMIT_MSG=$( sed ' /^#/d;/^[[:space:]]*$/d' " $COMMIT_MSG_FILE " )
302+ # Extended list of abusive words (case-insensitive).
303+ # Adjust the list as needed.
304+ ABUSIVE_WORDS_REGEX=' \b(fuck|fucking|dick|shit|bitch|asshole|cunt|motherfucker|damn|crap|dumbass|piss)\b'
305+ if echo " $FULL_COMMIT_MSG " | grep -Eiq " $ABUSIVE_WORDS_REGEX " ; then
306+ add_warning 1 " Commit message contains inappropriate language. Avoid using abusive words"
307+ fi
295308}
296309
297310unset GREP_OPTIONS
You can’t perform that action at this time.
0 commit comments