Skip to content

Commit e865a97

Browse files
authored
Create require-jira-issue.sh
1 parent b736096 commit e865a97

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
zero_commit="0000000000000000000000000000000000000000"
4+
5+
read oldrev newrev refname
6+
echo $oldrev $newrev $refname
7+
8+
check_message_format ()
9+
# enforced custom commit message format
10+
{
11+
message=`git cat-file commit $newrev | sed '1,/^$/d'`
12+
regex="/*\[jira-.*\]"
13+
echo "[COMMIT MESSAGE]:" $message
14+
if [[ $message =~ $regex ]];
15+
then
16+
echo "Commit message looks good!"
17+
exit 0
18+
else
19+
echo "[POLICY] Commit message does not contain a JIRA ticket #"
20+
exit 1
21+
22+
fi
23+
}
24+
25+
if [ "$newrev" = "$zero_commit" ]; then
26+
continue
27+
else
28+
check_message_format
29+
fi

0 commit comments

Comments
 (0)