Skip to content

Commit 6829143

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 4429424 commit 6829143

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hook.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ validate_commit_message() {
212212
# reset warnings
213213
WARNINGS=()
214214

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

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

0 commit comments

Comments
 (0)