Skip to content

Instantly share code, notes, and snippets.

@patrikjohansson
Created May 31, 2012 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrikjohansson/2841551 to your computer and use it in GitHub Desktop.
Save patrikjohansson/2841551 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Adds story/ticket number to original git commit template
# Add this file to .git/hooks/
git_commit_file=$1
temp=`mktemp /tmp/git-commit-message-XXXXXX`
story_number=`git branch | grep '^\*' | grep -o '[1-9][0-9]*$'`
if [ -n "$story_number" ]; then
(echo "\n[#$story_number]"; cat "$git_commit_file") > "$temp"
cat "$temp" > "$git_commit_file"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment