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 <grfn@gws.fyi>
This commit is contained in:
parent
1c98437079
commit
0d1f6d0592
1 changed files with 23 additions and 6 deletions
|
@ -235,6 +235,7 @@
|
||||||
;;
|
;;
|
||||||
(load! "+bindings")
|
(load! "+bindings")
|
||||||
(load! "+commands")
|
(load! "+commands")
|
||||||
|
(load! "cpp")
|
||||||
|
|
||||||
(load! "+private")
|
(load! "+private")
|
||||||
|
|
||||||
|
@ -592,31 +593,47 @@
|
||||||
["f"]
|
["f"]
|
||||||
(list "o" "Reset HEAD@{1}" #'magit-reset-head-previous))
|
(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 ()
|
(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
|
(let ((start-point (magit-read-starting-point
|
||||||
"Create and checkout branch for Clubhouse story"
|
"Create and checkout branch for Clubhouse story"
|
||||||
nil
|
nil
|
||||||
"origin/master")))
|
"origin/master")))
|
||||||
(if (magit-rev-verify start-point)
|
(if (magit-rev-verify start-point)
|
||||||
(let ((desc (magit-read-string-ns
|
(when-let ((desc (magit-read-org-clubhouse-branch-name)))
|
||||||
(format "Story description (to go after gs/ch%d/)"
|
|
||||||
story-id))))
|
|
||||||
(list
|
(list
|
||||||
(format "gs/ch%d/%s" story-id desc)
|
(format "gs/ch%d/%s" story-id desc)
|
||||||
start-point))
|
start-point))
|
||||||
(user-error "Not a valid starting point: %s" choice)))
|
(user-error "Not a valid starting point: %s" choice)))
|
||||||
(user-error "No currently clocked-in clubhouse story")))
|
(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))
|
(interactive (magit-read-org-clubhouse-branch-args))
|
||||||
(magit-branch-and-checkout branch start-point))
|
(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
|
(transient-append-suffix
|
||||||
#'magit-branch
|
#'magit-branch
|
||||||
["c"]
|
["c"]
|
||||||
(list "C" "Checkout Clubhouse branch" #'magit-checkout-org-clubhouse-branch))
|
(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)
|
;; (defun grfn/split-window-more-sensibly (&optional window)
|
||||||
;; (let ((window (or window (selected-window))))
|
;; (let ((window (or window (selected-window))))
|
||||||
|
|
Loading…
Reference in a new issue