SourceTree 1.3 makes it easy to navigate to JIRA issues which are associated with your commits – and in fact to other supporting information like Crucible reviews or any predictable pattern in a commit message that you can identify.
Linking a repository to a JIRA project
If you’re committing code to resolve a JIRA issue, you’ll normally include the JIRA issue number in the commit message, perhaps something like this:
PROJECTX-101 Fixed bad encoding on UTF-16 characters
Wouldn’t it be awesome if when you looked at that commit message in the log, that ‘PROJECTX-101’ was a link to the JIRA issue? Well, it turns out that’s really easy in 1.3.
Simply click the ‘Settings’ button on the repository toolbar, select the Advanced tab, and look for the ‘Commit Text Replacements’ section:
Here you can see one I prepared earlier. To create it, I clicked ‘Add’ and entered these details:
All I needed to do was specify the project prefix (every JIRA project has one of these), and supply the base URL for my JIRA installation. With this in place, SourceTree will search for all instances of ‘PROJECTX-<number>’ in commit messages, and will hyperlink it to the issue itself, like this:
Clicking that link would open the issue at https://jira.myproject.com/browse/PROJECTX-101 in your default web browser.
Advanced usage – other types of links
It’s not only JIRA issues which can be linked. If you change the ‘Replacement Type’ box you can see there’s anther helper option for Crucible projects (which works much the same way as JIRA), but there is also an ‘Other’ option, which allows you to specify your own text replacements in terms of regular expressions. They could be links to other tracking systems, or indeed any other kind of replacement. Here’s an example:
You can specify a regular expression pattern to search for in the commit message, and what text should replace it. You can use capture clauses (parenthesis in the regex pattern, variable names in the ‘Replace With’ field) in order to extract details and reformat them. The keen-eyed among you may have noticed that the screenshot above actually represents the same JIRA link replacement, just in raw regex form – notice how it is looking for the issue pattern, and then replacing it with HTML to form a link. So you can do anything you need to do to translate commit plain text into HTML of your choosing.
We hope you enjoy this SourceTree 1.3 feature!