Linking Commits with Tickets

Last updated by Adam West on March 24, 2015 12:41

One of the very useful features Codebase offers is the ability to update tickets from within a commit message.

From within a commit message you can change the status of a ticket (thereby closing it), mention work done on said ticket, and add time spent on a ticket. To ensure that tickets are updated from your commit messages you must first ensure your SCM is set up correctly.

Configuring your SCM

Configuring your SCM to update tickets in Codebase requires one simple parameter to be set correctly: the email address you commit with. Codebase attempts to match the email address in the author metadata of your commit to an email address within the account you're pushing to. If Codebase can't match the email address in the author field, and a user in the account it can't update the ticket.

If you're using SVN then you don't have anything to update since it only uses usernames in it's commit metadata.

To configure your email address follow the appropriate instructions below

Git

Run the following commands from a console

git config --global user.name 'Your Name' git config --global user.email 'email@example.com' 

Mercurial

Add the following lines to your ~/.hgrc (or on a Windows system in %USERPROFILE%\Mercurial.ini)

[ui] username = Your Name <email@example.com> 

Bazaar

Run the following command from a console

bzr whoami 'Your Name <email@example.com>' 

Updating Your Ticket

To reference a ticket from a commit (and link it back from the ticket), simply add the following in your commit message:

[touch: ticketnumber] 

For example:

[touch: 10] 

This will add a new update to your ticket with the body being that of your commit message.

Changing the Status

Updating a ticket status from a commit is a very simple operation, all you need to do is reference the number of the ticket you wish to update, and the name of status you want to update it to in the following format

[statusname: ticketnumber] 

For example:

[completed: 10] 

You can update multiple tickets at once by separating ticket numbers with a comma, for example:

[completed: 10,11,12] 

Adding Time

To add time to a ticket add the following to your commit message, after referencing a ticket:

{t:60} 

Where 60 is the amount of time added to your ticket. Note that this only works when referencing a single ticket.

Troubleshooting

Commit messages aren't updating tickets

It's most likely that your the email address in your SCM client does not match anything Codebase or atech identity has on record for you. If you're using Git, Mercurial or Bazaar, please ensure that the email address specified in your SCM client is configured correctly (see above).

Time isn't being added to tickets

Time can only be linked to a ticket when there is only one ticket specified in the commit message. Ensure that you're not referencing multiple tickets.