DEV Community

Maroun Maroun
Maroun Maroun

Posted on

Auto Link to Reference External Resources Based on the Reference ID in the Commit Message

Configuring auto links to reference external resources is one of the most helpful features of GitHub.

Configuring it will make the commit message clickable, and it'll reference the external resource (i.e. Jira).

I thought it'd be very useful if you could do the same but from the CLI. So I wrote a simple script that does that.

You should have two variables set:

  • REFERENCE_PATTERN - Pattern used in commit message
  • TARGET_URL - Link to the external system you want to link to

For example, to link Jira issues having pattern like "PS-1425", you should set REFERENCE_PATTERN to PS-\d\d\d\d, and the TARGET_URL should be set to

Once set, you simply run:

gitlink <SHA>

If only one issue is referenced in the commit message, it'll be opened in the browser. Otherwise, you'll get a list of links for the issue.

For example, having the following log:

Author: MarounMaroun <****  .com>
Date:   Tue Jun 30 23:16:30 2020 +0300

    BD-5562: handle missing user in the user service

When you run:

gitlink 7d21af686732bd1812f79c4c51ac98a903de5c3d

A new tab with the relevant issue will be opened:

Project in GitHub:

Top comments (0)