2020-06-19 05:24:06 +02:00
|
|
|
;;; tvl.el --- description -*- lexical-binding: t; -*-
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2020 Griffin Smith
|
2020-06-19 17:51:31 +02:00
|
|
|
;; Copyright (C) 2020 The TVL Contributors
|
2020-06-19 05:24:06 +02:00
|
|
|
;;
|
|
|
|
;; Author: Griffin Smith <grfn@gws.fyi>
|
|
|
|
;; Version: 0.0.1
|
2020-06-19 17:51:31 +02:00
|
|
|
;; Package-Requires: (s magit)
|
2020-06-19 05:24:06 +02:00
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This file provides shared utilities for interacting with the TVL monorepo
|
|
|
|
;;
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'magit)
|
2020-06-19 17:51:31 +02:00
|
|
|
(require 's)
|
2020-06-19 05:24:06 +02:00
|
|
|
|
2020-06-19 17:51:31 +02:00
|
|
|
(defgroup tvl nil
|
|
|
|
"Customisation options for TVL functionality.")
|
|
|
|
|
|
|
|
(defcustom tvl-gerrit-remote "origin"
|
|
|
|
"Name of the git remote for gerrit"
|
|
|
|
:group 'tvl)
|
|
|
|
|
2020-06-19 17:54:54 +02:00
|
|
|
(defcustom tvl-depot-path "/depot"
|
|
|
|
"Location at which the TVL depot is checked out."
|
|
|
|
:group 'tvl)
|
|
|
|
|
2020-06-19 17:51:31 +02:00
|
|
|
(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."
|
2020-06-19 05:24:06 +02:00
|
|
|
(interactive)
|
2020-06-19 17:51:31 +02:00
|
|
|
(magit-push-refspecs tvl-gerrit-remote
|
2020-06-24 03:26:29 +02:00
|
|
|
(tvl--gerrit-ref "canon")
|
2020-06-19 17:51:31 +02:00
|
|
|
nil))
|
2020-06-19 05:24:06 +02:00
|
|
|
|
|
|
|
(transient-append-suffix
|
2020-06-19 17:51:31 +02:00
|
|
|
#'magit-push ["r"]
|
|
|
|
(list "R" "push to Gerrit for review" #'magit-gerrit-push-for-review))
|
2020-06-19 05:24:06 +02:00
|
|
|
|
2020-06-24 22:14:00 +02:00
|
|
|
(define-suffix-command magit-gerrit-push-wip ()
|
|
|
|
"Push to Gerrit as a work-in-progress."
|
|
|
|
(interactive)
|
|
|
|
(magit-push-refspecs tvl-gerrit-remote
|
|
|
|
(concat (tvl--gerrit-ref "canon") "%wip")
|
|
|
|
nil))
|
|
|
|
|
|
|
|
(transient-append-suffix
|
|
|
|
#'magit-push ["r"]
|
|
|
|
(list "W" "push to Gerrit as a work-in-progress" #'magit-gerrit-push-wip))
|
|
|
|
|
2020-06-19 17:51:31 +02:00
|
|
|
(define-suffix-command magit-gerrit-submit ()
|
|
|
|
"Push to Gerrit for review."
|
|
|
|
(interactive)
|
|
|
|
(magit-push-refspecs tvl-gerrit-remote
|
2020-06-24 03:26:29 +02:00
|
|
|
(tvl--gerrit-ref "canon" '("submit"))
|
2020-06-19 17:51:31 +02:00
|
|
|
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
|
2020-06-24 03:26:29 +02:00
|
|
|
(tvl--gerrit-ref "canon"
|
2020-06-19 17:51:31 +02:00
|
|
|
'("Code-Review+2" "publish-comments" "submit"))
|
|
|
|
nil))
|
|
|
|
|
|
|
|
(transient-append-suffix
|
|
|
|
#'magit-push ["r"]
|
|
|
|
(list "P" "push, rubberstamp & submit to Gerrit" #'magit-gerrit-rubberstamp))
|
2020-06-19 05:24:06 +02:00
|
|
|
|
2020-06-19 17:54:54 +02:00
|
|
|
(defun tvl-depot-status ()
|
|
|
|
"Open the TVL monorepo in magit."
|
|
|
|
(interactive)
|
|
|
|
(magit-status tvl-depot-path))
|
|
|
|
|
2020-06-19 05:24:06 +02:00
|
|
|
(provide 'tvl)
|
|
|
|
;;; tvl.el ends here
|