What the easiest way to add JIRA key in commit message in Source Tree, can SourceTree get the key from the branch name?
Why bamboo doesn't recognize Jira key from merge commit with branch name like "Merge branch/JIRA-KEY-issue"?
I decided to add client commit-msg hook, which automatically adds JIRA Key in commit message from branch name, and checks JIRA Key in message
Linux #!/bin/bash BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) if [[ $BRANCH_NAME =~ KEY-[0-9]+ ]]; then echo -e "\n"$BASH_REMATCH >> $1 fi if ! grep -Pq "KEY-[0-9]{4,}" $1; then echo "Aborting commit due to commit message without JIRA-key." exit 1 fi Windows #!/bin/bash BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) TR=$(echo $BRANCH_NAME | sed -r 's/.*(KEY-[0-9]{4,}).*/\1/') if [[ -n $TR ]]; then echo -e "\n"$TR >> $1 fi if ! grep -Eq "KEY-[0-9]{4,}" $1; then echo "Aborting commit due to commit message without JIRA-key." exit 1 fi
where
KEY-[0-9]{4,} - JIRA Key with not less than 4 numbers
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.