Skip to content

Instantly share code, notes, and snippets.

@elecnix
Created September 28, 2011 02:15
Show Gist options
  • Save elecnix/1246823 to your computer and use it in GitHub Desktop.
Save elecnix/1246823 to your computer and use it in GitHub Desktop.
bugzid in git commit message, for lazy rabbits
#!/bin/bash
# First cd to your git repo
# Execute this script.
# Create a feature branch by the name of case you are working on.
# (The branch name can include a dash followed by a keyword or two)
# Work hard.
# 'git commit' will open your editor with bugzid:1234 filled-in.
# Append a message, and voilà!
echo '#!/bin/sh
case "$2,$3" in
template,)
sed -i "s/\$bugzid/$(git symbolic-ref HEAD|sed s#refs/heads/##|sed s#-.*##)/" "$1" ;;
*) ;;
esac
' > .git/hooks/prepare-commit-msg
chmod a+x .git/hooks/prepare-commit-msg
git config commit.template ~/.git-commit-template
echo 'bugzid:$bugzid' > ~/.git-commit-template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment