Skip to content

Commit 6a7ed7c

Browse files
committed
hook: Allow tag:/[tag]/{tag} prefixes in subject
This hook didn't detect cap'd subject when prefixed with tag:/[tag]/{tag} eg. tag(scope): Subject cap check failed [tag] Subject cap check failed {tag} Subject cap check failed '@(+([[:alnum:]])?(\(+([[:alnum:]])\)):|\[+([[:alnum:][:punct:]])\]|\{+([[:alnum:][:punct:]])\}|squash\!)' matches the prefixes and removes it from subject line before checking.
1 parent 178bfd8 commit 6a7ed7c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hook.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ validate_commit_message() {
130130
# reset warnings
131131
WARNINGS=()
132132

133-
# capture the subject, and remove the 'squash! ' prefix if present
134-
COMMIT_SUBJECT=${COMMIT_MSG_LINES[0]/#squash! /}
133+
# capture the subject, and remove the 'squash! ', 'tag: ', '[tag] ' or '{tag} ' prefix if present
134+
shopt -s extglob
135+
COMMIT_SUBJECT=${COMMIT_MSG_LINES[0]/#@(+([[:alnum:]])?(\(+([[:alnum:]])\)):|\[+([[:alnum:][:punct:]])\]|\{+([[:alnum:][:punct:]])\}|squash\!) /}
136+
shopt -u extglob
135137

136138
# if the commit is empty there's nothing to validate, we can return here
137139
COMMIT_MSG_STR="${COMMIT_MSG_LINES[*]}"

0 commit comments

Comments
 (0)