Skip to content

Instantly share code, notes, and snippets.

@ssherar
Last active August 29, 2015 14:16
Show Gist options
  • Save ssherar/e80809c8958a78ae037b to your computer and use it in GitHub Desktop.
Save ssherar/e80809c8958a78ae037b to your computer and use it in GitHub Desktop.
Looks for refs, closes or fixes in your commit message
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