about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-12-08T18·20-0500
committergrfn <grfn@gws.fyi>2021-12-09T02·08+0000
commitd4c765743ed7b29573f4ca4b4c2b05247a7f12eb (patch)
tree2487dac72eb28bb1ad4d168dd0d4a138fd0f4dfe /tools
parent49d4d12a735c61de87addf4f53ba23221b1842e3 (diff)
feat(tvl.el): Add magit-gerrit-cherry-pick r/3163
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
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs-pkgs/tvl/tvl.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/emacs-pkgs/tvl/tvl.el b/tools/emacs-pkgs/tvl/tvl.el
index 3938628edc8e..175c0c402939 100644
--- a/tools/emacs-pkgs/tvl/tvl.el
+++ b/tools/emacs-pkgs/tvl/tvl.el
@@ -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)