Created
September 24, 2015 16:28
-
-
Save cravecode/99b40192c959eb4c0aa9 to your computer and use it in GitHub Desktop.
Adds a GitHub Issue number to a commit message based on the branch name. I.e.: branch-name-123
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
#!/bin/bash | |
branchPath=$(git symbolic-ref -q HEAD) #Somthing like refs/heads/myBranchName | |
branchName=${branchPath##*/} #Get text behind the last / of the branch path | |
issueNumber=$(echo "$branchName" | grep -Po "\-\d+$" | grep -Po "\d+") | |
# If there was a issue number in the branch name, append it to the commit message. | |
if [ -n "$issueNumber" ]; then | |
# Write the issue number to the commit message. | |
echo "Issue: #$issueNumber" >> $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment