Last active
April 27, 2017 09:30
-
-
Save pzi/f909cfd749a44e993261c2a77e39462c to your computer and use it in GitHub Desktop.
Gets JIRA card number from git branch name and inserts it into the commit message.
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
function get-jira-card-number { | |
# Assuming branch names have the following body: XX-1234-Title, | |
# we are only interested in XX-1234. | |
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-8 | cut -d"-" -f 1-2 | |
} | |
function jira-card-number-commit { | |
local number=`get-jira-card-number` | |
local message=$1; | |
if [[ $number && -n $message ]]; then | |
git commit -m "$number: $message" | |
else | |
echo "Missing JIRA card number or message." | |
fi | |
} | |
alias jcm="jira-card-number-commit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment