Setting up Gertty for effective code review
Gertty is a console-based client for the Gerrit code review tool. Once you start doing a lot of code reviews as part of your daily work, gertty proves to be an excellent alternative to the Gerrit web interface. For one, it can work offline so it means it’s possible to review code while on the move. It also means the interface is more reactive since everything is cached locally. Plus the fact that it’s a console tool is really appealing to programmers who spend their life in the terminal.
However, like all great tools, it needs a bit of configuration it in order to deliver its full potential. I’m going to document here a few of the settings I’m using in the context of OpenStack.
Vim key bindings
If like me you like using the vim key bindings whenever possible, then you’re
in luck. Gertty ships with a vi keymap and allows you to remap most of the
controls. To enable the vi bindings simply set keymap: vi
in your
.gertty.yaml
file. However, don’t stop here or you’ll be heading for serious
disappointment. The default vi keymap is rudimentary with only the four
direction keys hjkl
and you’ll need to redefine most of the combinations to
feel at home.
Gertty supports key sequences in the form of [key1, key2]
so you can easily
emulate a leader key or a command like :q
.
Here is the configuration I am using for reference:
Right now, the only thing I’m missing are the G
and gg
movements to go to
the bottom or top of the panel. They are apparently missing from the underlying
urwid library.
Dashboards
In the spirit of the web interface, gertty also allows you to define your own dashboards. The syntax is a bit different though, and as a consequence the official OpenStack dashboards can’t be imported directly and need to be adapted slightly. Unfortunately, I couldn’t find documentation for gertty’s query interface, so until someone finds the courage and time to write it down, the source code remains your best resource.
Here is for example what I’m using for the Kolla project:
Keyword replacement
The OpenStack Gerrit instance conveniently replaces the git commit message tags it understands with links to Launchpad issues or blueprints. Gertty offers that feature through keyword replacements.
Here is for instance how to mimic that behavior:
Filter job results by pipelines
That last one hasn’t yet made it to gertty. This is somewhat specific to OpenStack gerrit instance and how it works with Zuul. The above commit lets you filter the job results by pipeline and displays useful information like the date or the number of rechecks.
See what gertty looks like with the patch applied: