Skip to content

Commit 3e33a12

Browse files
committed
Add 'stg branch' popup
Add popup to access the 'stg branch' command. Use the same command characters as the regular magit 'branch' command where possible. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
1 parent 14958eb commit 3e33a12

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

magit-stgit.el

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ one from the minibuffer, and move to the next line."
259259
("a" "Goto" magit-stgit-goto)]
260260
[("c" "Commit" magit-stgit-commit)
261261
("C" "Uncommit" magit-stgit-uncommit)
262+
("b" "Branch" magit-stgit-branch)
262263
("r" "Repair" magit-stgit-repair)
263264
("R" "Rebase" magit-stgit-rebase)]
264265
[("z" "Undo" magit-stgit-undo)
@@ -474,6 +475,67 @@ into the series."
474475
(magit-run-stgit "repair")
475476
(message "Repairing series...done"))
476477

478+
(transient-define-prefix magit-stgit-branch ()
479+
"Popup console for StGit branch."
480+
:man-page "stg-branch"
481+
["Arguments"
482+
("-f" "Force cleanup or deletion even if a branch has patches" "--force")]
483+
["Branch action"
484+
("c" "Create" magit-stgit-branch-create)
485+
("C" "Clone" magit-stgit-branch-clone)
486+
("m" "Rename" magit-stgit-branch-rename)
487+
("p" "Protect" magit-stgit-branch-protect)
488+
("u" "Unprotect" magit-stgit-branch-unprotect)
489+
("k" "Delete" magit-stgit-branch-delete)
490+
("K" "Cleanup" magit-stgit-branch-cleanup)])
491+
492+
;;;###autoload
493+
(defun magit-stgit-branch-create (start branch-name)
494+
"Create and switch to a new branch"
495+
(interactive (list (magit-read-starting-point "Create and checkout branch")
496+
(read-from-minibuffer "Name for new branch: ")))
497+
(magit-run-stgit "branch" "--create" branch-name start))
498+
499+
;;;###autoload
500+
(defun magit-stgit-branch-clone (target)
501+
"Clone the contents of the current branch"
502+
(interactive (list (read-from-minibuffer "New branch name: " (magit-get-current-branch))))
503+
(magit-run-stgit "branch" "--clone" target))
504+
505+
;;;###autoload
506+
(defun magit-stgit-branch-rename (old-name new-name)
507+
"Rename an existing branch"
508+
(interactive (list (magit-read-local-branch "Branch to rename")
509+
(read-from-minibuffer "New branch name: ")))
510+
(magit-run-stgit "branch" "--rename" old-name new-name))
511+
512+
;;;###autoload
513+
(defun magit-stgit-branch-protect (target)
514+
"Prevent StGit from modifying a branch"
515+
(interactive (list (magit-read-local-branch "Branch to protect")))
516+
(magit-run-stgit "branch" "--protect" target))
517+
518+
;;;###autoload
519+
(defun magit-stgit-branch-unprotect (target)
520+
"Allow StGit to modify a previously protected branch"
521+
(interactive (list (magit-read-local-branch "Branch to unprotect")))
522+
(magit-run-stgit "branch" "--unprotect" target))
523+
524+
;;;###autoload
525+
(defun magit-stgit-branch-delete (target &rest args)
526+
"Invoke `stg uncommit ARGS...'."
527+
(interactive (append (list (magit-read-local-branch "Branch to delete"))
528+
(transient-args 'magit-stgit-branch)))
529+
(magit-run-stgit "branch" "--delete" target args))
530+
531+
;;;###autoload
532+
(defun magit-stgit-branch-cleanup (target &rest args)
533+
"Invoke `stg uncommit ARGS...'."
534+
(interactive (append (list (magit-read-local-branch "Branch to clean up"))
535+
(transient-args 'magit-stgit-branch)))
536+
(magit-run-stgit "branch" "--cleanup" target args))
537+
538+
477539
(transient-define-prefix magit-stgit-rebase ()
478540
"Rebase the stack."
479541
:man-page "stg-rebase"

0 commit comments

Comments
 (0)