Linking Commit Messages to Redmine

As my projects became more complex, I wanted a more robust solution beyond the usual To-Do/Doing/Done boards.

After some research, I stumbled upon Redmine, a free and open-source project management tool. Readers might be familiar with Jira, a commercial solution widely used for similar purposes. I intend to dedicate more posts to Redmine as project management is a discipline on its own.

As it turns out, Redmine not only serves as a repository browser, but can also integrate with your version control system to update issues(tasks) statuses. For today's tip, I will show how to integrate Redmine issue tracking with SVN's commit message. So on every commit, it can update the status from "working" to "done" for example, set a percentage of completion and automatically log time spent on a task. This kind of task status automation for my projects is what I was looking for when I started my research into project management tools after all.

First things first: You have to add your project repository to your project setting's repository page. This will allow you to use Redmine as a repository browser.

Add your project repository in the project settings.

You can now browse through folders, commits, diffs and more in the Repository tab of the project!

With this, you can view latest changes to your project repository, but nothing is linked to Redmine yet. Let's fix that by adding a couple of SVN properties with Tortoise SVN.

In the root folder of your local copy, open Tortoise SVN's context menu, go to properties and add a new property. The first one you want to add is the "bugtraq:url" containing the URL of your Redmine's issues web page. Append the %BUGID% expression to the path(Which would look something like https://mydomain.redmine/issues/%BUGID%) so SVN will be able to link issues in places like commit logs and messages.

Next property to add is "bugtraq:logregex". Which will make the commit message recognize messages containg issue links. The one I'm currently using is:

(\s*(,|and)?\s*#\d+)+ #\d+

This will capture messages containing issue numbers preceded bt the "#" symbol. For example, by writing the commit message "Fixes issue #54, closes #55", both links to issues 54 and 55 will be available in the commit message as clickable URLs. These values will also be used to set issue statuses based on keywords which I will show in a bit.

As an option, you can add a property "tsvn:logtemplate" to prepopulate the commit message field with a default message. In my case, I added a template that allows me set the issue number and the spent time in the second line, as shown in the image below.

SVN Properties dialog.

The "@" symbol before the time spent is important: It's used by Redmine to update the time spend on the specified issue. So #53 @04:30 means you spent 4 hours and a half on issue 53.

The last step is customizing the automation based on keywords. This requires going into the global repository administration section of Redmine, so it will affect all your projects. Here is where you can set which words will trigger an increase in percentage completion of a task, or even change status from "doing" to "done", so customize this section according to your needs.

In the Redmine Administration you can customize the link between commit messages and issue statuses.

That's the first of many Redmine tips on this blog, and I'm only scratching the surface. A post about how about install plugins is also in order, as Redmine has a rich ecosystem of plugins created by the community. But that's it for today, or for the year rather, time really flew by.

See you next mission.

Next
Next

Turning Caps Lock Into an Useful Key