git alias for tagging commits with Jira ticket IDs
[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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment