Pages

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: java.io.IOException: Invalid tree 00ba05c8a75c3fdd3022fd87d92694e87556acb8:mode starts with '0'
        at org.eclipse.jgit.transport.PackParser.verifySafeObject(PackParser.java:959)
        at org.eclipse.jgit.transport.PackParser.whole(PackParser.java:940)
        at org.eclipse.jgit.transport.PackParser.indexOneObject(PackParser.java:858)
        at org.eclipse.jgit.transport.PackParser.parse(PackParser.java:467)
        at org.eclipse.jgit.storage.file.ObjectDirectoryPackParser.parse(ObjectDirectoryPackParser.java:178)
        at org.eclipse.jgit.transport.ReceivePack.receivePack(ReceivePack.java:832)
        at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:665)
        ... 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: