Gerrit is a great code review tool and a great git hosting service. This package provides an emacs interface for
gerrit-upload
)gerrit-download
and gerrit-download-transient
)gerrit-dashboard
)gerrit-section-topic-info
and gerrit-section-change-info
).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
.
March 2024:
gerrit-get-changeid-from-current-commit
to
gerrit-get-changeid-from-commit
with optional revision parameter.gerrit-get-unique-changeid-from-current-commit
to
gerrit-get-unique-changeid-from-commit
with optional revision
parameter.February 2024:
gerrit-rest-change-get-description
and
gerrit-rest-change-set-description
.gerrit-upload
: Do nothing if remote SHA1 matches SHA1 of HEAD.Dezember 2023:
gerrit-rest-change-delete-cr-vote
,
gerrit-rest-change-delete-reviewer
and
gerrit-rest-change-delete-verified-vote
.Use DELETE method for deleting verified votes + Improve rest-sync-v2
September 2022:
gerrit-upload-transient
, which allows
skipping the pre-push git hooks.August 2022:
gerrit-rest-sync-v2
.gerrit-dashboard-query-alist
(Include the "Your turn" in
the query, which requires a new-ish gerrit server release >= 3.3).gerrit--accounts-alist
. This allows
displaying the real names of the users instead usernames in the
dashboards and the query frontends.gerrit-dashboard-columns
.gerrit-dashboard-columns
.April 2022:
gerrit-query
function, which display the results
of a user defined gerrit query.tabulated-list-sort
(S). [Requested by Gerald]March 2022:
Februrary 2022:
gerrit-dashboard-columns
is customized.gerrit-use-ssl
.Jannuary 2022:
gerrit-use-gitreview-interface
variable is no longer used.gerrit-download
.October 2021:
gerrit-download-transient
, which will replace
the gerrit-download
function in the future.gerrit-download-transient
.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)))
.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.
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.
gerrit-upload
transientAll 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.
gerrit-dashboard
displays a dashboard similar to the one in the gerrit
web-interface. The currently supported keybindings in a dashboard buffer are
browse-url
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)))
magit-gerrit Fork of
https://github.com/emacsorphanage/magit-gerrit. Uses the
ssh
interface for performing gerrit requests.
gerrit-download Downloads
gerrit change and shows the diff in a diff buffer. Uses the git-review
command line tool under the hood.
gerrit-el reimplementation of the gerrit code review Web UI in emacs.