Skip to content

Commit a71d494

Browse files
authored
Merge pull request #135 from github/add-jira-hook
Pre-receive hook that checks for Jira Issue
2 parents 35d1d72 + 59ba5e2 commit a71d494

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#
3+
# check commit messages for JIRA issue numbers formatted as [JIRA-<issue number>]
4+
5+
REGEX="\[JIRA\-[0-9]*\]"
6+
7+
ERROR_MSG="[POLICY] The commit doesn't reference a JIRA issue"
8+
9+
while read OLDREV NEWREV REFNAME ; do
10+
for COMMIT in `git rev-list $OLDREV..$NEWREV`;
11+
do
12+
MESSAGE=`git cat-file commit $COMMIT | sed '1,/^$/d'`
13+
if ! echo $MESSAGE | grep -iqE "$REGEX"; then
14+
echo "$ERROR_MSG: $MESSAGE" >&2
15+
exit 1
16+
fi
17+
done
18+
done
19+
exit 0

0 commit comments

Comments
 (0)