Created
December 6, 2012 18:54
-
-
Save joshareed/4227080 to your computer and use it in GitHub Desktop.
Git hook for adding Lean-To tags to commit messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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