Last active
August 29, 2015 14:16
-
-
Save ssherar/e80809c8958a78ae037b to your computer and use it in GitHub Desktop.
Looks for refs, closes or fixes in your commit message
This file contains hidden or 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
FOUND=$( grep -iE "(refs|closes|fixes)" "$1" ) | |
BRANCH=$( git rev-parse --abbrev-ref HEAD | grep -Eo '[0-9]+' ) | |
if [[ -n $BRANCH ]] && [[ -z $FOUND ]]; then | |
echo "\033[1;34m > Found an issue within the branch, defaulting to $BRANCH \033[0m" | |
sed -i "" "2i\\ | |
refs #$BRANCH | |
" $1 | |
exit 0 | |
elif [[ -z $FOUND ]]; then | |
echo "\033[1;31m ! Haven't found a reference to a GH issue. exiting... \033[0m" | |
echo "--------------------------------" | |
head -10 $1 | grep -v "^#" | |
echo "--------------------------------" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment