How to get the issue key into the commit message automatically?

Intel CHD Jira Admin May 27, 2015

We're using the feature branch workflow with JIRA and Stash. Creating the branch from JIRA works perfectly, but when I commit on the branch I expect the commit message to be prefilled with the issue key automatically. If I commit without the key in the message the changeset won't show up Jira. But the commit message is empty, forcing me to go back to JIRA and copy and paste the key before committing - a waste of time. What am I doing wrong?

-David

2 answers

1 accepted

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2015

The commit message is entered on the client side and there is no way to populate it from Stash, unless you do some scripting on your git client.

At best, you can prevent pushes to Stash without having a proper issue key in the commit message. Yet Another Commit Checker worked well for me to validate the issue keys.

Intel CHD Jira Admin May 27, 2015

Thanks for the tip! I have to say I do find it disappointing that ST can't figure out that the user is working on a feature and extract the issue key and prefill it in the commit message. It's not rocket science, and after all Atlassian controls every part of the solution: Jira, Stash and SourceTree;). Atlassian goes to so much trouble to connect things and save the developer time and then they ignore this low hanging fruit and force him to switch tools just to get the issue key into the commit message. Doesn't make sense. Another more general approach would be a configuration option that uses a regular expression and whatever matches that expression in the current branch name is extracted and placed in the commit message. -David

Like rmarqques likes this
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2015

I like the regular expression check on ST. For now, ST is developed as a generic tool for any git solutions, not just for Stash, and that is probably why they do not have any hard coded rules. Any solution, should be a configurable one so that it can continue to work with other git servers like GitHub.

Intel CHD Jira Admin May 27, 2015

So I have made a feature request: https://jira.atlassian.com/browse/SRCTREEWIN-3261.

Intel CHD Jira Admin May 27, 2015

Hey Jobin, the solution is independent of the repo hosting solution and in fact all the information is present on the client side in a generic way. The branch name contains the Jira issue key, or more generally, some string matching a regular expression. That doesn't depend on Stash, Github, Foohub or Barhub. The rule is extract whatever matches that and put it in the commit message, as the default content. The solution that is hardcoded to a Jira issue key is also independent of the repo hosting solution, though it is of course hardcoded to the syntax of Jira issue keys. -David

Intel CHD Jira Admin May 27, 2015

Jobin, I have reworked the ST issue to specify the generic solution. Feel free to comment or vote: https://jira.atlassian.com/browse/SRCTREEWIN-3261. -David

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2015

But the commit message is empty

You mean that after committing with a commit message and pushing to Stash, the message is not there?

Intel CHD Jira Admin May 27, 2015

No. I mean when I am making the commit in ST, the commit message is not prefilled with the issue key. I have to manually go back to Jira and copy and paste it, or manually type it. A waste of time. ST can see I am working on a branch with an issue key. To make the workflow easily to execute it could just stick that into the commit message (before I commit of course - I might want to delete it - that should be up to the user). ST already knows about pull requests in Stash, so it's no big leap to say it should know about the feature branch workflow and provide some help.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events