• Archives

  • Categories:

Offline, CLI-based Gerrit code review with Gertty

This past week I headed to Florida to present at Fossetcon and thought it would be a great opportunity to do a formal review of a new tool recently released by the OpenStack Infrastructure team (well, mostly James E. Blair): Gertty.

The description of this tool is as follows:

As compared to the web interface, the main advantages are:

  • Workflow — the interface is designed to support a workflow similar to reading network news or mail. In particular, it is designed to deal with a large number of review requests across a large number of projects.
  • Offline Use — Gertty syncs information about changes in subscribed projects to a local database and local git repos. All review operations are performed against that database and then synced back to Gerrit.
  • Speed — user actions modify locally cached content and need not wait for server interaction.
  • Convenience — because Gertty downloads all changes to local git repos, a single command instructs it to checkout a change into that repo for detailed examination or testing of larger changes.

For me the two big ones were CLI-based workflow and offline use, I could review patches while on a plane or on terrible hotel wifi!

I highly recommend reading the announcement email to learn more about the features, but to get going here’s a quick rundown for the currently released version 1.0.2:

First, you’ll need to set a password in Gerrit so you can use the REST API. Do that by logging into Gerrit and going to https://review.openstack.org/#/settings/http-password

From there:

pip install gertty

wget https://git.openstack.org/cgit/stackforge/gertty/plain/examples/openstack-gertty.yaml -O ~/.gertty.yaml

Edit ~/.gertty.yaml and update anything that says “CHANGEME”

A couple things worthy of note:

  • Be aware that by default, uses ~/git/ for the git-root, I had to change this in my ~/.gertty.yaml so it didn’t touch my existing ~/git/ directory.
  • You can also run it in a venv, as described on the pypi page.

Now run gertty from your terminal!

When you first load it up, you get a welcome screen with some hints on how to use it, including the all important “press F1 for help”:

Note: I use xfce4-terminal and F1 is bound to terminal help, see the Xfce FAQ to learn how to disable this so you can actually read the Gertty help and don’t have to ask on IRC how to do simple things like I did ;)

As instructed, from here you hit “L” to list projects, this is the page where you can subscribe to them:

You subscribe to projects by pressing “s” and they will show up as bright white, then you can navigate into them to list open reviews:

Go to a review you want to look at and hit enter, bringing up the review screen. This should look very familiar, just text only. I’ve expanded my standard 80×24 terminal window here so you can get a good look at what the full screen looks like:

Navigate down to < Diff > to see the diff. This is pretty cool, instead of showing it on separate pages like the web UI, it shows you a unified page with all of the file diffs, so you just need to scroll through them to see them all:

Finally, you review! Select < Review > back on the main review page and it will pop up a screen that allows you to select your +2, +1, -1, etc and add a message:

Your reviews are synced along with everything else when Gertty knows it’s online and can pull down review updates and upload your changes. At any time you can look at the top right of your screen to see how many pending sync requests it has.

When you want to quit, CTRL-q

I highly recommend giving it a spin. Feel free to ask questions about usage in #openstack-infra and bugs are tracked in Storyboard here: https://storyboard.openstack.org/#!/project/698. The code lives in a stackforge repo at: http://git.openstack.org/cgit/stackforge/gertty

2 Comments

  • fungi

    Great article! From a somewhat frequent user, a few additional tips…

    1. Your screenshots used an 80-column terminal–if you regularly work at that width consider switching the config to use a unified inline diff rather than side-by-side.

    2. Your ? key will get you the help screen without needing a working F1.

    3. Gertty is designed to coexist with your command-line git workfow and use the same repository directories as long as you organize them the same way–I’ve been using it that way without issue (so far at least).

 




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>