Created
November 9, 2011 15:40
-
-
Save schnipseljagd/1351823 to your computer and use it in GitHub Desktop.
prepare commit message wih refs generation
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 | |
# | |
# prepends the current branch to the commit subject | |
# replace it if a commit got e. g. cherry-picked | |
# | |
BRANCH=$(git name-rev --name-only HEAD) | |
# strip possible old branch (if cherry-picked) | |
COMMIT_MSG=$(sed -r -e 's/\([a-z0-9-]+\) //ig' $1) | |
#add reference dummy if in branch dev and not in commit message | |
REFS='' | |
if [[ "$BRANCH" == "dev" && !("$COMMIT_MSG" =~ "refs #") ]]; then | |
REFS='refs #' | |
fi | |
echo -e "($BRANCH) $REFS$COMMIT_MSG" > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment