Last active
June 8, 2020 20:23
-
-
Save samnela/d97d897eb9b96aca0c48663074f5009c to your computer and use it in GitHub Desktop.
Add the jira ticket number from the 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/bash | |
COMMIT_MSG_FILE=$1 | |
COMMIT_SOURCE=$2 | |
branchName=`git rev-parse --abbrev-ref HEAD` | |
branchToSkip=(master develop) | |
message=$(cat "$COMMIT_MSG_FILE") | |
for branch in ${branchToSkip[*]} | |
do | |
if [[ $branch == $branchName ]] | |
then | |
exit 0 | |
fi | |
done | |
jiraId=$(echo $branchName | sed -nr 's,[a-z]+/([A-Z]+-[0-9]+)-.+,\1,p') | |
if [[ ! -z $jiraId ]] && ! [[ $message == $jiraId* ]] | |
then | |
echo "${jiraId}: $message" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment