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.

Caching

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
           URL: https://review.openstack.org/282340
           Author: Chaozhe Chen(ccz) (Chaozhe.Chen) <chaozhe.chen@easystack.cn>
           Topic: update-flake8
           Subject: Use '#flake8: noqa' to skip file check

[PATCH     ] 281835,2 openstack/nova
           URL: https://review.openstack.org/281835
           Author: Roman Dobosz (gryf) <roman.dobosz@intel.com>
           Topic: bug-1546433
           Subject: Add annotation to the kill() method

[COMMENT   ] 282324,3 openstack/fuel-octane
           URL: https://review.openstack.org/282324
           Author: Yuriy Taraday (yorik-sar) <yorik.sar@gmail.com>
           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 https://review.openstack.org/240944
             Add sanity tests for testing actions with Port
[COMMENT   ] 282334,1 openstack/fuel-octane gelbuhos https://review.openstack.org/282334
             Workflow 1 Code-Review 2 
[COMMENT   ] 282334,1 openstack/fuel-octane gelbuhos https://review.openstack.org/282334
[COMMENT   ] 275844,23 openstack/kolla elemoine https://review.openstack.org/275844
             Workflow 1 Code-Review 2 
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos https://review.openstack.org/279478
             Verified 2 
[MERGED    ] 279478,3 openstack/fuel-octane gelbuhos https://review.openstack.org/279478
[COMMENT   ] 248938,29 openstack/neutron slaweq https://review.openstack.org/248938
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos https://review.openstack.org/279478
[COMMENT   ] 279478,3 openstack/fuel-octane gelbuhos https://review.openstack.org/279478
[COMMENT   ] 276419,1 openstack/glance siuzannatb https://review.openstack.org/276419
             Workflow 1 Code-Review 2 
[COMMENT   ] 276814,18 openstack/fuel-web vkramskikh https://review.openstack.org/276814
             Verified 1 
[COMMENT   ] 276419,1 openstack/glance siuzannatb https://review.openstack.org/276419
[COMMENT   ] 281472,2 openstack/ironic-webclient krotscheck https://review.openstack.org/281472
             Verified 1 
[COMMENT   ] 282331,1 openstack/fuel-qa apanchenko https://review.openstack.org/282331

Gruf, a Gerrit command line utility

Tue 16 February 2016 by Lars Kellogg-Stedman Tags gerrit gruf

(See also the followup to this article.)

I've recently started spending more time interacting with Gerrit, the code review tool used both by OpenStack, at review.openstack.org, and by a variety of other open source projects at GerritForge's GitHub-linked review.gerrithub.io. I went looking for command line tools ...

read more