-
Notifications
You must be signed in to change notification settings - Fork 1
/
commit-msg
executable file
·22 lines (21 loc) · 1012 Bytes
/
commit-msg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# commit message has to start with either "XXX-123:" or "NOJIRA:" or "Merge branch"
test "" = "$(head -1 "$1" | grep -vE '^((fixup\!|squash\!) )?([A-Z]+\-[0-9]+:|NOPR:|NOJIRA:|HOTFIX:|Merge branch|Merge remote-tracking branch|Revert).+')" || {
echo >&2 'Aborting due to invalid commit message.'
echo >&2 '--> Commit message needs to be prefixed by either pull-request or JIRA number.'
echo >&2 ' e.g. "GH-123: blah" or "NOPR: blah" or "HOTFIX: blah"'
echo >&2 '--> Rejected commit message is...'
cat $1 | while read line; do
[ `expr "$line" : "^#"` -gt 0 ] && break
echo $line
done
exit 1
}