Philip Pittle
Philip Pittle

Reputation: 12295

Auto hyperlink Jira Issues in Git commits in SourceTree

Jira will automatically scan a git repo and pull in commits that are tagged with a Jira ID (ie QA-244).

Is there a way to display the links to Jira issues from with SourceTree:

enter image description here

Upvotes: 11

Views: 7285

Answers (2)

Mr-IDE
Mr-IDE

Reputation: 7641

To make the commit text in SourceTree link to a GitHub Issue or Bitbucket Issue (a simple bug 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/issues/$1/">#$1</a>$2 (make sure you include the speech marks)
    • b. On Windows, enter https://bitbucket.org/your_username/your_project/issues/$1
    • c. For GitHub, use https://github.com/your_username/your_project/issues/$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, 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:


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 the same regular expression and hyperlink from Step 6 and 7b. More info here.

Upvotes: 13

LasstLos
LasstLos

Reputation: 264

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

Upvotes: 14

Related Questions