Created
March 23, 2017 23:49
-
-
Save blacktaxi/39f94ad77be5d0d4f76479ea4b767f3e to your computer and use it in GitHub Desktop.
git alias for tagging commits with Jira ticket IDs
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
[alias] | |
# commit with Jira ticket ID tag in commit message. | |
# current branch name has to start with a valid Jira ticket ID, in upper case. | |
c = "!f() { \ | |
if [[ -z $1 ]]; \ | |
then \ | |
echo "Error: No commit message provided."; \ | |
exit 1; \ | |
else \ | |
local ticketId=$(git rev-parse --abbrev-ref HEAD | grep -Eo "^[A-Z]+-[0-9]+"); \ | |
if [[ -z $ticketId ]]; \ | |
then git commit -m $1 ${@:2}; \ | |
else git commit -m \"$ticketId $1\" ${@:2}; \ | |
fi; \ | |
fi; \ | |
}; f" |
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
$ git branch | |
* SF-123 | |
master | |
$ git c "Shaving yaks" | |
[SF-123 fd1b2e6] SF-123 Shaving yaks | |
1 file changed, 1 insertion(+), 1 deletion(-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment