How and why to use issue navigation patterns in PhpStorm

While everyone’s so excited about the Drupal 8 RC2 release, and is tweeting and blogging about it like a hell, I thought it might be interesting to step back and get to one of my favorite topics — IDE tricks, one which I’m going to show your right away.

PhpStorm has one of the nicest visual tools for browsing and working with all things Git, however I can’t stop discovering something new. This time it’s the ability to link individual commits to the corresponding task tracker issues. If you’re using some sort of tracker obviously.

Open Preferences and go to the Version control >> Issue navigation screen.

If you’re a Jira person, there is a predefined pattern for you, if you’re using Redmine or something more advanced like ERPAL, click on the leftmost «+» icon.

Next, you will have to figure out the regexp pattern to catch the issue ID in each commit. In my case the commits are looking like this:

[#97028] Refactor something

So we need to catch the issue ID in square brackets, which can be done like so:

\[#([0-9]+)\]

The tool will help to test the pattern. In case you have a more complex string to parse, it may take some time to figure it out. Use the https://regex101.com or similar tool for assistance.

Lastly, open the Version control log of your repository (or hit Cmd (Ctr) + 9 shortcut), and enjoy the results.

More on the topic in the official docs here https://www.jetbrains.com/phpstorm/help/issue-navigation.html

Igor Kandyba's Image
Igor Kandyba
Minsk, Belarus

I'm building Drop Guard - the ultimate continuous security solution for Drupal