Last active
December 18, 2015 03:08
-
-
Save ckoppelman/5715841 to your computer and use it in GitHub Desktop.
Githook for requiring a JIRA issue in the commit message like [REALM-1234]. Place this in .git/hooks/
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/sh | |
message=`cat $1` | |
prevLang=`echo $LANG` # this will get reset once we're done here | |
rc=0 | |
# The Portable-Git that comes with Github for Windows has a bash version of 3.1.0, | |
# so it doesn't understand regex matching. Use pattern matching instead. | |
# regex="(\[[A-Z]{2,5}-[0-9]{1,6}\]|\[NO-ISSUE\])" | |
pattern="*\[@(NO-ISSUE|[A-Z]+([A-Z])-+([0-9]))\]*" | |
export LANG="C.UTF-8" # apparently a case-sensitive regex is dependent on collation! | |
if [[ $message != $pattern ]] | |
then | |
echo "[POLICY] Your message does not contain a JIRA issue. Include [NO-ISSUE] if that's true." | |
rc=1 | |
fi | |
export LANG="$prevLang" | |
exit $rc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not supported by Github for Windows since that uses libgit and not git.