Auto hyperlink Jira Issues in Git commits in SourceTree

To make the commit text in SourceTree link to a GitHub Issue or Bitbucket Issue (standard issue tracker, similar to Jira), where the Issue is in the form "#1234", use this approach:

  1. Open your repository window
  2. Click 'Settings' in the toolbar
  3. Click 'Advanced'
  4. In the 'Commit Text Replacements' section, click 'Add'
  5. For the Replacement Type, select 'Other'
  6. In the 'Regex Pattern' field, enter #(\d+)($|[^a-zA-Z0-9-]) (but see the Note below)
  7. In the 'Replace With' field:
    • a. On Mac OS X, enter <a href="https://bitbucket.org/your_username/your_project/issue/$1/">#$1</a>$2 (make sure you include the speech marks)
    • b. On Windows, enter https://bitbucket.org/your_username/your_project/issue/$1
  8. Click OK twice
  9. Re-select the commit log item which has a mention of the #12345 style issue number. It should now show a clickable hyperlink to the issue, which will open your web browser.

Note: For step 6, you may consider using a regex like #(\d{1,4})($|[^a-zA-Z0-9-]) to prevent matching URLs that have "#numbers" in them, like www.example.com/#123456 - More info here

Sources:

  • https://confluence.atlassian.com/sourcetreekb/link-to-bitbucket-issue-tracker-from-commits-296911608.html
  • https://answers.atlassian.com/questions/237742/sourcetree-what-format-is-link-to-url-for-commit-text-links

Apply the same links in JetBrains products

You can also have the same links in IntelliJ IDEA, Android Studio, PyCharm, etc, when viewing the "Version Control" tab for Git history:

IDE -> Preferences -> Search for "Issue Navigation" -> Add -> Enter regular the same expression and hyperlink. More info here.


Information on setting this up can be found here

Basically just set up text replacement for all your project abbreviations with the URL that they point to. My windows version was a little different than documented there and went like this:

enter image description here

enter image description here

enter image description here

enter image description here