Gerrit is an open-source code-review system for Git. It gives you a nice web interface for conversing about commits, giving and getting feedback, auto-merging reviewed commits, and even has options for hooking in your automated test. While I don’t feel like it’s a perfect solution by any means, and I dislike the way it changes the basic way Git works – these changes were probably necessary in developing a code-review system around Git. I’d be curious on how other projects like Crucible (not free), CodeCollaborator (not free), or ReviewBoard handle it. (Actual reviews of some of these on this blog.)

A few quick things to note:

  • Gerrit is made by guys at Google and is used in well known projects such as the Android platform and is used at companies like digg.com.
  • I found it fairly easy to setup, just run it’s .war file and answer a few questions (few prerequisites below).
  • The Gerrit platform internally, uses a java implementation of git as well as it’s own java SSH daemon. Wonder why? I did too, and posted in the Gerrit Google Group, and got some helpful answers.

Getting started

  • Before hand you should have mysql running with an empty database (default: reviewdb)
  • Decide on which port you want to run the Jetty webserver beforehand, and which port you want to run the SSH daemon (it must be different than your default one). I recommend you not run any SSH daemons on the default port (22) if your server is directly accessibly from the internet.
  • To be secure, you should prepare a separate unix user that gerrit runs as (container process), as well as a gerrit mysql user with full access to the reviewdb.
  • You should also have SMTP setup either on the server or through another source – note that you cannot just use sendmail, as I also asked here.

Quick commands:

cd /tmp
wget http://gerrit.googlecode.com/files/gerrit-2.2.1.war
 # run the install wizard
sudo java -jar gerrit-2.2.1.war init -d /srv/gerrit

During the install, when it asks you if you want to copy the war file, agree.
sudo java -jar gerrit-2.2.1.war daemon -d /srv/gerrit # to test it out

Other Helpful Info

gerrit’s home is:
/srv/gerrit

Create /etc/default/gerritcodereview containing the line:
GERRIT_SITE=/srv/gerrit
so you can use the shell script for turning off / on:

As for SMPTP you can just set up a gerrit.yourdomain gmail account. Mark SSL encryption on port 443.