File tree 1 file changed +7
-11
lines changed
1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change 18
18
# the commit message file is the last remaining arg
19
19
msg_file=" $1 "
20
20
21
- # join types with | to form regex ORs
22
- r_types=" ($( IFS=' |' ; echo " ${types[*]} " ) )"
23
- # optional (scope)
24
- r_scope=" (\([[:alnum:] \/-]+\))?"
25
- # optional breaking change indicator and colon delimiter
26
- r_delim=' !?:'
27
- # subject line, body, footer
28
- r_subject=" [[:alnum:]].+"
29
- # the full regex pattern
30
- pattern=" ^$r_types$r_scope$r_delim$r_subject $"
21
+ commit_msg_type_regex=' feat|fix|refactor|style|test|docs|build'
22
+ commit_msg_scope_regex=' .{1,20}'
23
+ commit_msg_subject_regex=' .{1,100}'
24
+ commit_msg_regex=" ^(${commit_msg_type_regex} )(\(${commit_msg_scope_regex} \))?: (${commit_msg_subject_regex} )\$ "
31
25
merge_msg_regex=" ^Merge branch '.+'\$ "
32
26
27
+ commit_msg_header=$( git show -s --format=%s $msg_file )
28
+
33
29
# Check if commit is conventional commit
34
- if grep -Eq " $pattern | $ merge_msg_regex" " $msg_file " ; then
30
+ if ! [[ " $commit_msg_header " =~ ( ${commit_msg_regex} ) | ( ${ merge_msg_regex} ) ]] ; then
35
31
exit 0
36
32
fi
37
33
You can’t perform that action at this time.
0 commit comments