Gerrit Productivity Hacks – Plugin For Gmail
Today, as a part of Gerrit Productivity Hacks Series, I would like to point you to a relatively new Google Chrome extension: Gerrit Plugin for Gmail, which can significantly speed up your code review process. How does it work? Here is an excerpt from the plugin page:
This Chrome extension aims to implement a very basic Gerrit workflow into your Gmail, based on the emails Gerrit sends. Specifically,
- It formats your Gerrit messages in Gmail.
- New changes and patch sets will include colored, unified diffs of the changes.
- Makes Gerrit emails easier to read by removing noise and highlighting important bits with HTML-formatting.
- For new patch sets, the unified diffs included is diffed against the last-commented-upon patch set, rather than Base, so you can more easily track the evolution of the change.
- It incorporates Gerrit functionality in Gmail.
- On unified diffs, double-click a line to comment on the line.
- On comment emails, you can respond to a comment in-line from Gmail.
- Convenient shortcuts: "w" to open change in Gerrit, and "W" to approve the change
- Approve, submit, rebase from Gmail.
It does sound tempting, doesn’t it?
We will go through the basic use case scenarios for this plugin and will show what’s cool about it. Finally, we will have a look at the installation and configuration process.
But first let’s have a look at an email from Gerrit in Gmail once the plugin is enabled:
The interesting parts have been highlighted in orange. There are two of them: the lower one allows you to instantly comment on the change. The other one (in the upper left corner) displays the status of the change. Let’s have a closer look:
What we see here is the change Id (6422 in this case) , its status (Unverified) and four buttons:
View– opens the given change in a new tab
Comment– allows to comment on the given change
Approve– gives +2 Code-Review on the given change
& Submit– gives +2 Code-Review and tries to submit the change in question
As you see it is very simple, yet efficient UI for reviewing changes and it makes emails from Gerrit way more useful. If you want to go directly to change in Gerrit, just type ‘w’. Even better, if you type ‘W’ (ctrl+w) your change will be instantly approved. Here is how the status looks like after using ctrl+w shortcut:
Wow, that was fast. Yes, we’ve just approved the change from Gmail by pressing ctrl+w. And we also see in Gmail, that the change status has changed to
Approved, which is also visually indicated with green color. Now we are ready to submit the change using
Submit button. At least if nothing speaks against. In my case Jenkins does, as I still need verification from it. So pressing the
Submit button will result with this:
Well, at least I see what’s needed. But once Jenkins verifies the change I press submit button again, the change get submitted and the status part looks good again:
Let’s have a look at another email:
Here we can see a single question (in yellow) that has been asked about the commit message, so it is very handy to write your answer (comment) inline (the orange box) and submit it from Gmail.
And it gets even better when the patch you are going to review addresses the issues you commented on. Like in this case:
What we see here is a nicely formatted info that all requested issues have been addressed. So, we can already use Approve & Submit button (or press ctrl+W) to submit this change. That way we are done with reviewing really fast.
Another thing worth mentioning is how diffs look like. So, here is an example:
As you see the diffs are nicely formatted, and what’s important, the diff is performed against the previous patch as opposed to the base, which in my opinion makes more sense.
Last thing I wanted to show you is what happens when verification from Jenkins fails:
Note the “See Error” button? It might save you one click, as it goes directly to the console output of the Jenkins job in question. Of course, the standard Gerrit link which will bring you back to the failed job overview page is still accessible from the email.
I hope I have already convinced you to try this plugin. Now it is time to have a look at the installation.
It is very simple. First, you have to install this Chrome extension. After installation go to: Chrome -> Tools -> Extension and click on Options (yellow in the screenshot below).
Now it’s time to configure this extension. All we need to do is to provide Gerrit Url and the Gmail account. You can also specify the number of context lines and Bot names for automated users. Here is how the configuration looks like in my case:
After clicking the save button we are done with configuration and it’s time to check if everything is set-up properly. So let’s have a look:
Hmm, it does not look good in the right upper corner: we’ve got authentication error message. But that’s actually expected. I haven’t log into Gerrit Web UI yet, and our plugin requires us to do that – it uses the same authentication as Gerrit Web UI. So let’s log-in into Gerrit and look at our page again. Now, the error is gone and we are ready to use the plugin.
The Gerrit Plugin for Gmail has neat features that make Gerrit emails much more useful and helps you to get stuff done faster which, in turn improves your productivity. I wouldn’t say it is a replacement for Gerrit UI but I do feel it is a nice extension that lets you shorten the path to approve a change and makes your life easier.