Created
August 4, 2014 22:01
-
-
Save aaronstaves/eca5dd4b692f6cfb34b9 to your computer and use it in GitHub Desktop.
JIRA branch names commit 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/bash | |
line=`head -n 1 "$1"` | |
if [[ ${#line} == 0 ]] | |
then | |
echo "No commit message, commit aborted" | |
exit -1 | |
else | |
exit 0 | |
fi | |
# Put in BASE_DIR/.git/hooks/commit-msg. Make Executable. | |
#!/bin/bash | |
branch=`git rev-parse --abbrev-ref HEAD` | |
branchRegex='([A-Z_]+?)(-[0-9]+)' | |
if [[ $branch =~ $branchRegex ]] | |
then | |
sed -i "1s/^/\n\n${BASH_REMATCH[1]}${BASH_REMATCH[2]}/" $1 | |
fi | |
# Put in BASE_DIR/.git/hooks/prepare-commit-msg. Make executable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment