twmr / gerrit.el

gerrit integration in emacs
44 stars 5 forks source link
dashboard emacs gerrit magit melpa

Build Status MELPA

gerrit.el

Gerrit is a great code review tool and a great git hosting service. This package provides an emacs interface for

The function gerrit-upload uses the transient package and provides the following features in addition to uploading new changes (and new patchsets)

Furthermore, a minimalistic open-reviews status-section (gerrit-magit-insert-status) for magit status buffers is available.

This code is tested using gerrit=3.8 and the gerrit version used on review.gerrithub.org.

News

March 2024:

February 2024:

Dezember 2023:

Use DELETE method for deleting verified votes + Improve rest-sync-v2

September 2022:

August 2022:

April 2022:

March 2022:

Februrary 2022:

Jannuary 2022:

October 2021:

Installation

This emacs package is available on MELPA.

Example use-package config

(use-package gerrit
  :ensure t
  :custom
  (gerrit-host "gerrit.my.domain")  ;; is needed for REST API calls
  :config
  (progn
    (add-hook 'magit-status-sections-hook #'gerrit-magit-insert-status t)
    (global-set-key (kbd "C-x i") 'gerrit-upload-transient)
    (global-set-key (kbd "C-x o") 'gerrit-download)))

Authentication

.authinfo, .authinfo.gpg and .netrc

By default emacs searches in files called ~/.authinfo, ~/.authinfo.gpg and ~/.netrc in the specified order for credentials. Take a look at the auth-sources variable and its documentation if you want to change this.

You can add an entry with the following format to any of above files

machine gerrithostname.org
    login my-gerrit-username
    password xxxx

Note: Depending on your auth configuration, Gerrit may expect a generated HTTP password (ex. if you have git_basic_auth_policy="HTTP_LDAP"). If there is an HTTP credentials section in your user's account settings page, then an HTTP password needs to be generated and supplied in your auth-source file.

Pre-commit hook

As you know, there is a gerrit pre-commit hook that must be installed for every gerrit repo s.t. the Change-ID is added to the bottom of your git commit messages. This pre-commit hook can be installed using the gerrit--ensure-commit-msg-hook-exists function or e.g. by calling git review -s provided that the git-review CLI tool is installed.

Screenshots

gerrit-dashboard

gerrit-download

gerrit-upload

gerrit-section-change-info

Usage notes for the gerrit-upload transient

All settings entered in the gerrit-upload transient are saved to a file, whose filename is in the transient-history-file variable. This file is updated in the kill-emacs-hook, which is run when the emacs process/daemon is stopped using (kill-emacs).

If you are using systemd for starting emacs as a daemon, make sure that your unit files contains

ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"

You can cycle through the history by using M-p and M-n.

The reviewers have to be added as a comma-separated string. Completion of the individual reviewers using the account information from the gerrit servers should work with TAB.

Dashboards

gerrit-dashboard displays a dashboard similar to the one in the gerrit web-interface. The currently supported keybindings in a dashboard buffer are

It is possible to click on the links in the dashboard buffer to open new query buffers like in the gerrit webfrontend.

If you want to create multiple dashboards you can create a dashboard using

(defun gerrit-dashboard-standup ()
  (interactive)
  (let ((gerrit-dashboard-query-alist
         '(
           ("Waiting for +1" . "is:open assignee:groupX label:Code-Review=0")
           ("Waiting for +2" . "is:open assignee:groupX label:Code-Review=1")
           )
         )
        (gerrit-dashboard-buffer-name "*gerrit-groupX-standup*")
        )
    (gerrit-dashboard)))

Similar elisp packages