Streamlined code reviews with PivotalTracker and GitHub

Where i work we use GitHub for scm and PivotalTracker for our task management. When we started with our code reviews we wanted the pull request process to be as unobtrusive as possible. Here is what we did to automate as much as possible.

Our code review workflow

  1. Start the task in PivotalTracker
  2. Create a new feature branch by checking out origin/develop under a new name.
  3. Prefix all commits with [#task_id] to have them show up in PivotalTracker.
  4. When you are done prefix your last commit message with [fixes #task_id]. This will mark the PivotalTracker task as “Fixed” and a pull request will be created automatically.
  5. When you peer has reviewed the code and wants to merge it, he or she should prefix the merge message with [delivers #task_id]. If the last commit was correctly prefixed with [fixes #task_id], this is only a matter of changing one word as the last commit message will be pre-populated with the last commit message automatically.
  6. Delete the branch using the button that appears after merging the PR.

The improvements to the usual process are that you never have to go to PivotalTracker and click “Done”, or “Deliver”. You also never have to go to and create a PR every time. This is all done automatically via a GitHub service hook and a local pre-push hook.

Making it happen

  1. Set up a service hook in GitHub for PivotalTracker. Go to repository settings via the wrench icon on the right on your repository page on GitHub. Then click Webooks & Services and finally Add service and select PivotalTracker. Paste your API key from PivotalTracker and you’re set.
  2. Install “hub” via homebrew: brew install –HEAD hub
    You may need to invoke hub pull-request manually once to feed it your GitHub login details.
  3. Install this script as a pre-push hook by putting it in .git/hooks/ in your project and making it executable with chmod +x .git/hooks/

Now, whenever you push a local branch not named develop or master to origin, and the commit message contains the text [fixes #task_id] a pull request will be created automatically for your peers to review. Isn’t that neat?

One thought on “Streamlined code reviews with PivotalTracker and GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *