Skip to content

Instantly share code, notes, and snippets.

@saghaulor
Created January 21, 2014 19:52
Show Gist options
  • Save saghaulor/8547089 to your computer and use it in GitHub Desktop.
Save saghaulor/8547089 to your computer and use it in GitHub Desktop.
#!/bin/sh
# borrowed heavily from http://stackoverflow.com/a/17270862
jiraNumber=$(git branch | grep '*' | egrep -io '[C][[:alpha:]][-[:digit:]]+')
firstLine=$(head -n1 $1)
if [ -z "$firstLine" ] ;then # Check that this is not an amend by checking that the first line is empty
sed -i "" "1s/^/$jiraNumber /" $1 # Insert branch name at the start of the commit message file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment