2019-09-26 04:18:27 +02:00
# Gerrit widget
2019-11-24 03:57:26 +01:00
It shows number of currently assigned reviews in [Gerrit ](https://www.gerritcodereview.com/ ) to the user (by default) :
2019-11-24 03:54:52 +01:00
![gerrit_widget ](./gerrit_widget.png )
2019-11-24 04:06:56 +01:00
when clicked it shows reviews in a list:
2019-11-24 03:54:52 +01:00
![popup ](./popup.png )
2019-11-24 04:02:49 +01:00
left click on an item will open review in the default browser, right click will copy the review number, which you can use to checkout this review by running `git-review -d <review number>` .
2019-11-24 03:54:52 +01:00
Also, if a new review is assigned to the user, there will be a pop-up:
![new_review ](./new_review.png )
2019-09-26 04:18:27 +02:00
## Customization
It is possible to customize widget by providing a table with all or some of the following config parameters:
| Name | Default | Description |
|---|---|---|
2019-11-24 03:54:52 +01:00
| `icon` | `/.config/awesome/awesome-wm-widgets/gerrit-widget/gerrit_icon.svg` | Path to the icon |
2019-09-26 04:18:27 +02:00
| `host` | Required | Ex https://gerrit.tmnt.com |
| `query` | `is:reviewer AND status:open AND NOT is:wip` | Query to retrieve reviews |
## Prerequisite
- [curl ](https://curl.haxx.se/ ) - is used to communicate with gerrit's [REST API ](https://gerrit-review.googlesource.com/Documentation/rest-api.html )
2019-09-26 04:21:37 +02:00
- setup [netrc ](https://ec.haxx.se/usingcurl-netrc.html ) which is used to store username and password in order to call API's endpoints.
2019-09-26 04:18:27 +02:00
## Installation
2019-11-06 03:54:24 +01:00
1. This widget relies on Gerrit [REST API ](https://gerrit-review.googlesource.com/Documentation/rest-api.html ), so you need to have a permission to access it. You also need to setup [netrc ](https://ec.haxx.se/usingcurl-netrc.html ), as widget uses curl to communicate with API and you have to be authenticated.
2019-11-06 04:02:56 +01:00
To test if you have access to API and netrc setup is correct run following command, you should have a json response:
2019-11-06 04:04:31 +01:00
```bash
curl -s --request GET --netrc https://gerrit-host.com/a/changes/\?q\=status:open+AND+NOT+is:wip+AND+is:reviewer | tail -n +2
```
Note: `tail -n +2` is needed to skip first line of the response, as gerrit returns some characters there in order to prevent XSS hacks.
2019-11-06 03:54:24 +01:00
2019-09-26 04:18:27 +02:00
1. Download json parser for lua from [github.com/rxi/json.lua ](https://github.com/rxi/json.lua ) and place it under ** ~/.config/awesome/** (don't forget to star a repo):
```bash
wget -P ~/.config/awesome/ https://raw.githubusercontent.com/rxi/json.lua/master/json.lua
```
1. Clone this repo (if not cloned yet) under ** ~/.config/awesome/**:
```bash
git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/
```
2019-09-26 04:21:37 +02:00
1. Require widget at the top of the **rc.lua** :
2019-09-26 04:18:27 +02:00
```lua
local gerrit_widget = require("awesome-wm-widgets.gerrit-widget.gerrit")
```
1. Add widget to the tasklist:
```lua
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
--default
gerrit_widget({host = 'https://gerrit.tmnt.com'}),
--customized
gerrit_widget({
host = 'https://gerrit.tmnt.com',
query = 'is:reviewer AND is:wip'
})
...
```
2019-11-06 04:04:31 +01:00