.git/hooks/prepare-commit-hook
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/sh | |
# This hook appends "Fixes #123." to the commit message | |
# when you're on a branch with "bug-###" in the branch name.e.g., post-by-email-bug123; bug123-post-by-email | |
# Note: I find it easier to do the first one because autocomplete is more useful that way. | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
bug=$(echo $branch | sed -n 's/^.*bug-\([[:digit:]]*\).*/\1/ p') | |
original_commit=$(head -n 1 $1) | |
if [ -n "$bug" -a -z "$original_commit" ] | |
then | |
/usr/bin/perl -i.bak -npe "s/^/\n\nFixes #$bug./s if \$. == 1" "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment