Created
May 27, 2017 19:34
-
-
Save rdelandesen/b7d18b1247cae6b1cd3ad47bde6ed44b to your computer and use it in GitHub Desktop.
Commit message with JIRA branch name
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 | |
# | |
# Prepend the branch name to the commit message | |
# | |
# Example | |
# # On branch BRA-1_homepage | |
# git commit -m "Responsive menu" | |
# # => [BRA-1] Responsive menu | |
# | |
# Add this file as [repo]/.git/hooks/prepare-commit-msg | |
# | |
NAME=$(git symbolic-ref --short HEAD | sed 's/_.*//') | |
DESCRIPTION=$(git config branch."$NAME".description) | |
echo '['"$NAME"'] '$(cat "$1") > "$1" | |
if [ -n "$DESCRIPTION" ] | |
then | |
echo "" >> "$1" | |
echo $DESCRIPTION >> "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment