feat(emacs-pkgs/tvl): Add magit shortcuts for reviews & co
Introduces two new shortcuts in the magit popup for pushing: * R: Push for review * S: Push to submit The existing "P" command remains, but has been renamed to "rubberstamp" and documented with a warning. To make this work across people's different setups, customisation options for TVL-specific code are being added. Change-Id: I48e75db55b5f793342fc898093629e437f58dcb2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/503 Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
b72d232075
commit
e7f8bdd548
2 changed files with 48 additions and 9 deletions
|
@ -6,5 +6,5 @@ trivialBuild rec {
|
||||||
pname = "tvl";
|
pname = "tvl";
|
||||||
version = "1.0";
|
version = "1.0";
|
||||||
src = ./tvl.el;
|
src = ./tvl.el;
|
||||||
packageRequires = [ magit ];
|
packageRequires = [ magit s ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
;;; tvl.el --- description -*- lexical-binding: t; -*-
|
;;; tvl.el --- description -*- lexical-binding: t; -*-
|
||||||
;;
|
;;
|
||||||
;; Copyright (C) 2020 Griffin Smith
|
;; Copyright (C) 2020 Griffin Smith
|
||||||
|
;; Copyright (C) 2020 The TVL Contributors
|
||||||
;;
|
;;
|
||||||
;; Author: Griffin Smith <grfn@gws.fyi>
|
;; Author: Griffin Smith <grfn@gws.fyi>
|
||||||
;; Version: 0.0.1
|
;; Version: 0.0.1
|
||||||
;; Package-Requires: (cl-lib magit)
|
;; Package-Requires: (s magit)
|
||||||
;;
|
;;
|
||||||
;; This file is not part of GNU Emacs.
|
;; This file is not part of GNU Emacs.
|
||||||
;;
|
;;
|
||||||
|
@ -15,18 +16,56 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'magit)
|
(require 'magit)
|
||||||
|
(require 's)
|
||||||
|
|
||||||
(define-suffix-command magit-push-and-submit ()
|
(defgroup tvl nil
|
||||||
|
"Customisation options for TVL functionality.")
|
||||||
|
|
||||||
|
(defcustom tvl-gerrit-remote "origin"
|
||||||
|
"Name of the git remote for gerrit"
|
||||||
|
:group 'tvl)
|
||||||
|
|
||||||
|
(defun tvl--gerrit-ref (target-branch &optional flags)
|
||||||
|
(let ((flag-suffix (if flags (format "%%l=%s" (s-join "," flags))
|
||||||
|
"")))
|
||||||
|
(format "HEAD:refs/for/%s%s" target-branch flag-suffix)))
|
||||||
|
|
||||||
|
(define-suffix-command magit-gerrit-push-for-review ()
|
||||||
|
"Push to Gerrit for review."
|
||||||
(interactive)
|
(interactive)
|
||||||
(magit-push-refspecs
|
(magit-push-refspecs tvl-gerrit-remote
|
||||||
"origin" "HEAD:refs/for/master%l=Code-Review+2,publish-comments,submit"
|
(tvl--gerrit-ref "master")
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(transient-append-suffix
|
(transient-append-suffix
|
||||||
#'magit-push
|
#'magit-push ["r"]
|
||||||
["r"]
|
(list "R" "push to Gerrit for review" #'magit-gerrit-push-for-review))
|
||||||
|
|
||||||
(list "P" "Push and submit to gerrit" #'magit-push-and-submit))
|
(define-suffix-command magit-gerrit-submit ()
|
||||||
|
"Push to Gerrit for review."
|
||||||
|
(interactive)
|
||||||
|
(magit-push-refspecs tvl-gerrit-remote
|
||||||
|
(tvl--gerrit-ref "master" '("submit"))
|
||||||
|
nil))
|
||||||
|
|
||||||
|
(transient-append-suffix
|
||||||
|
#'magit-push ["r"]
|
||||||
|
(list "S" "push to Gerrit to submit" #'magit-gerrit-submit))
|
||||||
|
|
||||||
|
|
||||||
|
(define-suffix-command magit-gerrit-rubberstamp ()
|
||||||
|
"Push, automatically approve and submit to Gerrit. This
|
||||||
|
rubberstamp operation is dangerous and should only be used in
|
||||||
|
`//users'."
|
||||||
|
(interactive)
|
||||||
|
(magit-push-refspecs tvl-gerrit-remote
|
||||||
|
(tvl--gerrit-ref "master"
|
||||||
|
'("Code-Review+2" "publish-comments" "submit"))
|
||||||
|
nil))
|
||||||
|
|
||||||
|
(transient-append-suffix
|
||||||
|
#'magit-push ["r"]
|
||||||
|
(list "P" "push, rubberstamp & submit to Gerrit" #'magit-gerrit-rubberstamp))
|
||||||
|
|
||||||
(provide 'tvl)
|
(provide 'tvl)
|
||||||
;;; tvl.el ends here
|
;;; tvl.el ends here
|
||||||
|
|
Loading…
Reference in a new issue