I recently spearheaded a campaign at my workplace to move from a problematic system of building releases using patching and SVN to the more modern, widely accepted Git approach. Things are moving along pretty well, and everyone is starting to get acclimated, but we found ourself with a little confusion with respect to code review.

Previously, reviews were done on the patches attached to issues in our bug tracking solution. Now people are a little confused as to where to go to do code review. The solution I created involves creating private posts in pastebin and providing the link as a comment in the issue. It's basically a stop gap until we get something like Crucible+Fisheye for more intelligent code review.

I realized rather quickly on that I needed to make it as easy as possible to create diffs and share them from the command line, where I'm encouraging people to do all their work with respect to Git. I created the following command-line function:

In other words, pop this into your bash profile, or a separate script that you source during logon, and you have yourself a script that interacts with the Pastebin API and returns the URL of the new post. Here's an example of how we plan on using it:

# after merging your ticket branch to the dev branch, "next"
# and any commits you need to make locally in case next has changed since branching
$ git diff origin/next next | pastebin

So you basically grab that URL and comment it in the ticket, and that snippet is available for review. You can use this function for anything, too. Just make sure to change up the format specification (or remove it all together), and remove the privacy specification if you intend to make it public.