Gruf gets superpowers

Fri 19 February 2016 by Lars Kellogg-Stedman Tags gerrit gruf

In my last article article I introduced Gruf, a command line tool for interacting with Gerrit. Since then, Gruf has gained a few important new features.


Gruf will now by default cache results for five minutes. This avoids repeatedly querying the server for the same information when you're just displaying it with different templates (for example, if you run a gruf query open here followed by a gruf -t patches query open here).

The cache lifetime can be tuned on the command line (with the --cache-lifetime option) or in the gruf.yml configuration file (as the cache_lifetime parameter). Gruf has also learned the invalidate-cache command if you want to clear out the cache.

Better streaming

I have substantially enhanced the support for the Gerrit stream-events command.

Automatic reconnection

Gruf will now automatically reconnect to the Gerrit server if the connection is lost while streaming events.

Better default templates

The default stream-events template now produces colorized output, and there is also a short template that produces one or two line output for each event that can be useful if you just want to see what's going on.

The default output looks like this:

[PATCH     ] 282340,1 openstack/gnocchi
           Author: Chaozhe Chen(ccz) (Chaozhe.Chen) <>
           Topic: update-flake8
           Subject: Use '#flake8: noqa' to skip file check

[PATCH     ] 281835,2 openstack/nova
           Author: Roman Dobosz (gryf) <>
           Topic: bug-1546433
           Subject: Add annotation to the kill() method

[COMMENT   ] 282324,3 openstack/fuel-octane
           Author: Yuriy Taraday (yorik-sar) <>
           Topic: 282317
           Subject: Remove unused password param from restore command

    Patch Set 3: Code-Review+2 Workflow+1

The short output looks something like this:

[PATCH     ] 240944,24 openstack/python-ironicclient sturivnyi
             Add sanity tests for testing actions with Port
[COMMENT   ] 282334,1 openstack/fuel-octane gelbuhos
             Workflow 1 Code-Review 2 
[COMMENT   ] 282334,1 openstack/fuel-octane gelbuhos
[COMMENT   ] 275844,23 openstack/kolla elemoine
             Workflow 1 Code-Review 2 
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos
             Verified 2 
[MERGED    ] 279478,3 openstack/fuel-octane gelbuhos
[COMMENT   ] 248938,29 openstack/neutron slaweq
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos
[COMMENT   ] 276419,1 openstack/glance siuzannatb
             Workflow 1 Code-Review 2 
[COMMENT   ] 276814,18 openstack/fuel-web vkramskikh
             Verified 1 
[COMMENT   ] 276419,1 openstack/glance siuzannatb
[COMMENT   ] 281472,2 openstack/ironic-webclient krotscheck
             Verified 1 
[COMMENT   ] 282331,1 openstack/fuel-qa apanchenko