A simple code review script for Git


This January, Ksplice swelled from 8 people to 20 people. You can imagine what that did to the office—it’s a good thing that Tim and Jeff have been practicing the art of rearranging a space to fit more people than ever thought possible since their days in the SIPB office. Fortunately, because we have at our disposal a computer-systems training and recruitment machine of awesome effectiveness, our interns defied Fred Brooks and produced a great deal of useful code.

The problem: how to keep track of all that new code and get it all reviewed smoothly? Our ad hoc practices relying on one-on-one exchanges clearly were not going to scale. The solution: on the first day the new interns showed up, I took a couple of hours and threw together a script to request code reviews. The key design considerations were

  • Public visibility. The script sends mail, and CCs a list going to the whole team.
  • Non-diffusion of responsibility. The user must identify someone to be the reviewer, and the request is addressed to them.
  • Git friendliness. Being a kernel shop, we use Git for everything, so the script assumes a basic Git workflow: you make some commits, and then you request a whole series of commits to be reviewed at once.

We looked at some existing code review tools like Gerrit and Rietveld, but we weren’t happy with any of them because the ones we found don’t work on branches—they work on individual commits—and we have drunk too deeply of Git to be satisfied working that way.

On the other hand, being the product of a few hours’ work, there’s several things that could be made better. The interaction with the user could be better to prevent mis-sends. The script could do better at detecting what the repository in question is called, it could take advantage of commit messages for better subject lines, and it could try to give the reviewer a command line that will show the commits in question. (Until then: it’s usually git log -p --reverse origin/master..origin/branchname.) Someday we may also want a system that tracks what commits have been reviewed by whom and blocks commits from going in without review; that will be a bigger project.

Apparently we did something right with this script, because I heard a couple of people say they’d like to use it outside of Ksplice. So the other day we decided we were happy to release it as free software. As of last night you can get it from Github—enjoy.

Let me know if you use it, and patches welcome, of course.

Written by Greg Price

February 1st, 2010 at 3:56 am

Posted in Uncategorized

Tagged with , , ,

3 Responses to 'A simple code review script for Git'

Subscribe to comments with RSS or TrackBack to 'A simple code review script for Git'.

  1. [...] a post on the Ksplice blog, our first substantive post, following an intro post by Waseem. As I mentioned last month, we swelled from 8 to 20 people this January with interns, and were triumphant in making the whole [...]

  2. Hi, I am interested in your code review script. Could you help me understand how it works please?
    Also, what settings do I need to change so it knows where my git clone is for instance? We don’t use github, we clone a central repo into workspaces.
    I appreciate any help you can offer.


    23 Jun 11 at 1:26 pm

  3. Hi Marlene,

    For a general understanding of how the script works, the best resource is the source code itself, which I link to above. To use it, cd into your working directory and run the script; it has a help message (which you can also read in the source code) for the arguments you can pass to it.

    The only settings you need to change are the two up at the top of the source code, concerning what email addresses to send to. In particular, it doesn’t have anything to do with Github — Ksplice doesn’t use Github either, except as a place to publish bits of code like this one for other people to use.

    If you have more specific questions, I’m happy to answer them.

    Greg Price

    24 Jun 11 at 4:05 am

Leave a Reply