Last active
December 17, 2015 03:19
-
-
Save solocommand/5542878 to your computer and use it in GitHub Desktop.
Hook to force commit messages to start with JIRA issue identifiers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
regex='^[A-Z]{2,6}-[0-9]{1,8}\s' | |
message="$(sed 's/^#.*//' $1 | grep -v '^$')" | |
if [[ $message =~ $regex ]] ; then | |
echo -e >&2 "\e[0;32mCommit linked issue\e[m ${BASH_REMATCH[0]}" | |
else | |
echo -e >&2 "\e[0;31mCommit failed: Invalid JIRA Key: $message\e[m" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment