Sunday, February 05, 2012

Gerrit: code review for Git

Since we are getting more and more in trouble with SourceForge :( I started looking into the more standard git code review environment, called Gerrit, so that we can use that for the CDK. With some huge learning curve, lurking, googling, and seeing what Avagadro was doing (resulting in my first ever, trivial Avogadro patch), and a major headache. This is what my patch looks like in Avogadro's Gerrit install:

As you can see, Marcus reviewed my patch, and approved it. I am not sure if they have configured to have Gerrit automatically push to GitHub, but that is an option.

It turns out I could not find documentation how to set up Gerrit for a GitHub project, but ended up installing it. That basically consists of setting up MySQL (or equivalent) with a user account and database, create a Linux account, and then follow the install instructions in a .war file. Next then is to register an account, and it nicely picks up a Google Account, but OpenID seems supported too. The first account is automatically the administration account, and that is a good choice indeed.

Finding the right documentation for creating a new project from an existing project was tricky, and I ended up with this instruction. However, typing the second step in that:

git push ssh://egonw@localhost:29418/cdk *:*

causes this output:

Counting objects: 181366, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (32350/32350), done.
fatal: Unpack error, check server log 4.30 MiB | 8.54 MiB/s   
error: pack-objects died of signal 13
error: failed to push some refs to 'ssh://egonw@localhost:29418/cdk'

With this stacktrace in Gerrit's error log:

Caused by: Invalid tree 00ba05c8a75c3fdd3022fd87d92694e87556acb8:mode starts with '0'
        at org.eclipse.jgit.transport.PackParser.verifySafeObject(
        at org.eclipse.jgit.transport.PackParser.whole(
        at org.eclipse.jgit.transport.PackParser.indexOneObject(
        at org.eclipse.jgit.transport.PackParser.parse(
        at org.eclipse.jgit.transport.ReceivePack.receivePack(
        at org.eclipse.jgit.transport.ReceivePack.service(
        ... 15 more

It seems I am running into this know bug :( I added my experience with Gerrit 2.2.2 to the report, but the original issue is over a year old. There is little comment, let alone a workaround, so this project is now on hold... :(

Update: I figured out how to set up a git repository manually on the Gerrit server, and managed to to push a patch for review:


  1. Egon, you want replication and we automatically mirror repositories to a few locations including Github. The Kitware Gerrit server contains some extra code to allow for reviews and merges of entire topics - we are in the process of getting this merged upstream. If you have any issues with Gerrit please let me know, I think it is a great tool and we are working with upstream.

    1. OK! I'm discussing setting up Gerrit here at BiGCaT now, and hope to ask you about this triggers soon :)