feat(tvl.el): Add magit-gerrit-cherry-pick

Bound to `A g`, this behaves similarly to `magit-gerrit-checkout` - it
prompts for a CL number, then cherry-picks the latest patchset of that
CL number

Change-Id: Ieef970b99d96170e8c960cc7687ead9022948f8b
This commit is contained in:
Griffin Smith 2021-12-08 13:20:57 -05:00 committed by grfn
parent 49d4d12a73
commit d4c765743e

View file

@ -142,10 +142,30 @@ rubberstamp operation is dangerous and should only be used in
(magit-checkout "FETCH_HEAD" (magit-branch-arguments))
(message "HEAD detached at %s" cl-refspec))
(transient-append-suffix
#'magit-branch ["l"]
(list "g" "gerrit CL" #'magit-gerrit-checkout))
(transient-define-suffix magit-gerrit-cherry-pick (remote cl-refspec)
"Prompt for a CL number and cherry-pick the latest patchset of that CL"
(interactive
(let* ((remote tvl-gerrit-remote)
(cl (magit-read-cl remote)))
(list remote cl)))
(magit-fetch-refspec remote cl-refspec (magit-fetch-arguments))
;; That runs async, so wait for it to finish (this is how magit does it)
(while (and magit-this-process
(eq (process-status magit-this-process) 'run))
(sleep-for 0.005))
(magit-cherry-copy (list "FETCH_HEAD"))
(message "HEAD detached at %s" cl-refspec))
(transient-append-suffix
#'magit-cherry-pick ["m"]
(list "g" "Gerrit CL" #'magit-gerrit-cherry-pick))
(defun tvl-depot-status ()
"Open the TVL monorepo in magit."
(interactive)