How can I automate Pivotal Tracker & Github Integration?

Tamas Kalman picture Tamas Kalman · Dec 14, 2012 · Viewed 9.5k times · Source

Pivotal Tracker and Github have great integration: Once it's set up, each commit which is prefixed by the Pivotal Tracker ID will appear under the corresponding Pivotal Ticket automatically, for an example:

git commit -am '[#1234567] my new changes'
git push origin

will add the comment 'my new changes' automatically to the 1234567 Pivotal Ticket among with the github commit link.

However, it's easy to forget to add the ticket ID each time. How could it be simplified / automated?

Answer

Tamas Kalman picture Tamas Kalman · Dec 14, 2012

The solution is to use Git-Hooks and feature branches. (The Github-flow is recommended).

You have to install this Git-Hook (copy a file to your local repository):

https://github.com/ktamas77/git_hooks

Before you start working on a particular Pivotal Ticket, you create a branch prefixed with the Pivotal Tracker ID, for an example:

git checkout 1234567_build_new_form

then add all your changes as you'd do normally:

git commit -am 'form added'
git commit -am 'styles added'
git push origin

you'll see, the git hook script will automatically extract the Pivotal Tracker ID from the feature branch name and add it to the front of each comment. You can still manually override it (with another ID) if you want.

In this way you don't have to worry about adding the Pivotal ID manually for every single commit. It also works with GUIS (such as GIT Tower) since these GUIs are using the standard GIT libraries / executables.