Skip to content

Commit b0c6fea

Browse files
committed
chore(git): update commit-msg hook
1 parent 6c5a751 commit b0c6fea

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

.dev/githooks/commit-msg

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
shopt -s lastpipe
33

44
scopes_file=".dev/scopes.txt"
5+
test -r $scopes_file &&
6+
scopes="($(cat "$scopes_file" | sed '/^\(#.*\|\)$/d' | sed ':a;N;s/\n/|/g;ta'))"
57

6-
scopes="("
7-
cat "$scopes_file" | while read a;
8-
do test -z "$a" || [[ "$a" == \#* ]] || scopes+="$a|";
9-
done;
10-
scopes="${scopes%\|})"
11-
12-
cat "$1" | grep -Eq "(fix|feat|docs|style|refactor|test|chore|rework|release)(\($scopes(/.+)?\))?: [a-z]"
8+
grep -Eq "(fix|feat|docs|style|refactor|test|chore|rework|release)(\(${scopes:-.*}(/.+)?\))?: [a-z]" "$1"
139
result=$?
1410
if test $result -ne 0
15-
then echo "Please check that the commit message adheres to the guidelines at http://karma-runner.github.io/latest/dev/git-commit-msg.html and the scope is one of $scopes as defined in $scopes_file"
11+
then echo "Please check the guidelines at http://karma-runner.github.io/latest/dev/git-commit-msg.html$(test -n "$scopes" && echo ", the scope should be one of $scopes as defined in $scopes_file")"
1612
fi
1713
exit $result

0 commit comments

Comments
 (0)