Created
August 1, 2013 08:25
-
-
Save brb/6129507 to your computer and use it in GitHub Desktop.
Git hook for appending an issue id into commit messages. The issue id is taken from branch name which should be in a "foobar-ISSUE-ID" format.
This file contains 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/bash | |
regexp=".*-([A-Z].*-[0-9]*)" | |
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | |
if [[ "$branch" =~ $regexp ]]; then | |
refs_id=${BASH_REMATCH[1]} | |
if [ "$2" = message ]; then | |
echo -ne "\n${refs_id}" >> "$1" | |
else | |
sed -i "1s/^$/\n\n${refs_id}/g" "$1" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment