From 0d1f6d059258ce01a46830c30de0b5c965995368 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Wed, 9 Sep 2020 11:59:14 -0400 Subject: feat(gs/emacs): Add command to rename branch after Clubhouse ticket Similar to the b C command to create a *new* branch named after a clubhouse ticket, add a new b M command to *rename* a branch after the currently clocked-in clubhouse ticket. Change-Id: I750106f5d417517fd8114536d9dc0905380d616a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1970 Tested-by: BuildkiteCI Reviewed-by: glittershark --- users/glittershark/emacs.d/config.el | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'users/glittershark') diff --git a/users/glittershark/emacs.d/config.el b/users/glittershark/emacs.d/config.el index aaca78e4c7..f584e8c898 100644 --- a/users/glittershark/emacs.d/config.el +++ b/users/glittershark/emacs.d/config.el @@ -235,6 +235,7 @@ ;; (load! "+bindings") (load! "+commands") +(load! "cpp") (load! "+private") @@ -592,31 +593,47 @@ ["f"] (list "o" "Reset HEAD@{1}" #'magit-reset-head-previous)) + (defun magit-read-org-clubhouse-branch-name () + (when-let ((story-id (org-clubhouse-clocked-in-story-id))) + (let ((desc + (magit-read-string-ns + (format "Story description (to go after gs/ch%d/)" + story-id)))) + (format "gs/ch%d/%s" story-id desc)))) + (defun magit-read-org-clubhouse-branch-args () - (if-let ((story-id (org-clubhouse-clocked-in-story-id))) + (if (org-clubhouse-clocked-in-story-id) (let ((start-point (magit-read-starting-point "Create and checkout branch for Clubhouse story" nil "origin/master"))) (if (magit-rev-verify start-point) - (let ((desc (magit-read-string-ns - (format "Story description (to go after gs/ch%d/)" - story-id)))) + (when-let ((desc (magit-read-org-clubhouse-branch-name))) (list (format "gs/ch%d/%s" story-id desc) start-point)) (user-error "Not a valid starting point: %s" choice))) (user-error "No currently clocked-in clubhouse story"))) - (define-suffix-command magit-checkout-org-clubhouse-branch (branch start-point) + (transient-define-suffix magit-checkout-org-clubhouse-branch (branch start-point) (interactive (magit-read-org-clubhouse-branch-args)) (magit-branch-and-checkout branch start-point)) + (transient-define-suffix magit-rename-org-clubhouse-branch (old new) + (interactive + (let ((branch (magit-read-local-branch "Rename branch"))) + (list branch (magit-read-org-clubhouse-branch-name)))) + (when (and old new) + (magit-branch-rename old new))) + (transient-append-suffix #'magit-branch ["c"] (list "C" "Checkout Clubhouse branch" #'magit-checkout-org-clubhouse-branch)) - ) + (transient-append-suffix + #'magit-branch + ["c"] + (list "M" "Rename branch to Clubhouse ticket" #'magit-rename-org-clubhouse-branch))) ;; (defun grfn/split-window-more-sensibly (&optional window) ;; (let ((window (or window (selected-window)))) -- cgit 1.4.1