Skip to content

Instantly share code, notes, and snippets.

@joshareed
Created December 6, 2012 18:54
Show Gist options
  • Save joshareed/4227080 to your computer and use it in GitHub Desktop.
Save joshareed/4227080 to your computer and use it in GitHub Desktop.
Git hook for adding Lean-To tags to commit messages
#!/bin/sh
# A commit hook script that automatically tags commits for Lean-To integration if you use a branching scheme
# bug/<num> or story/<num>
#
# Drop this file into your repos .git/hooks/ directory as 'commit-msg'
LEANTO="1179"
# figure out bug/story and id
TYPE=`git rev-parse --abbrev-ref HEAD | perl -n -e'/(bug|story)\/(\d+)/i && print lc($1)'`
ID=`git rev-parse --abbrev-ref HEAD | perl -n -e'/(bug|story)\/(\d+)/i && print lc($2)'`
ALREADY=`perl -n -e'/(\[.*?\s*(bug|story)\s*:\s*\d+\s*.*?\])/i && print $1' "$1"`
# check that the branch matches
if [ "" != "$TYPE" ] && [ "" != "$ID" ] && [ "" == "$ALREADY" ]; then
echo "\n\n[$TYPE:$ID] http://lean-to.com/1179/~/$TYPE/$ID" >> "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment