Skip to content

Commit 9a8dfdc

Browse files
committed
Convert rebase popup
1 parent fcb9a7a commit 9a8dfdc

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

magit-stgit.el

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ one from the minibuffer, and move to the next line."
262262
[("c" "Commit" magit-stgit-commit)
263263
("C" "Uncommit" magit-stgit-uncommit)
264264
("r" "Repair" magit-stgit-repair)
265-
("R" "Rebase" magit-stgit-rebase-popup)]
265+
("R" "Rebase" magit-stgit-rebase)]
266266
[("z" "Undo" magit-stgit-undo-popup)
267267
("Z" "Redo" magit-stgit-redo-popup)]]
268268
["Patch"
@@ -474,28 +474,33 @@ into the series."
474474
(magit-run-stgit "repair")
475475
(message "Repairing series...done"))
476476

477-
(magit-define-popup magit-stgit-rebase-popup
478-
"Popup console for StGit rebase."
479-
'magit-stgit-commands
480-
:switches '((?n "Do not push the patches back after rebasing" "--nopush")
481-
(?m "Check for patches merged upstream" "--merged"))
482-
:actions '((?R "Rebase" magit-stgit-rebase))
483-
:default-action #'magit-stgit-rebase)
477+
(transient-define-prefix magit-stgit-rebase ()
478+
"Rebase the stack."
479+
:man-page "stg-rebase"
480+
["Arguments"
481+
("-n" "Do not push the patches back after rebasing" "--nopush")
482+
("-m" "Check for patches merged upstream" "--merged")]
483+
["Actions"
484+
("R" "Rebase" magit-stgit--rebase)])
484485

485486
;;;###autoload
486-
(defun magit-stgit-rebase (&rest args)
487-
"Rebase a StGit patch series.
488-
Use ARGS to pass additional arguments"
489-
(interactive (magit-stgit-rebase-arguments))
490-
(let* ((branch (magit-get-current-branch))
491-
(remote (magit-get-remote branch)))
492-
(if (not (and remote branch))
493-
(user-error "Branch has no upstream")
494-
(when (y-or-n-p "Update remote first? ")
495-
(message "Updating remote...")
496-
(magit-run-git-async "remote" "update" remote)
497-
(message "Updating remote...done"))
498-
(magit-run-stgit "rebase" args "--" (format "remotes/%s/%s" remote branch)))))
487+
(defun magit-stgit--rebase (remote branch &rest args)
488+
"Invoke `stg rebase ARGS... remotes/REMOTE/BRANCH'.
489+
490+
If called interactively, use the current branch and its remote,
491+
and ask whether to update the remote first."
492+
(interactive (append (let* ((branch (magit-get-current-branch))
493+
(remote (magit-get-remote branch)))
494+
(if (and remote branch)
495+
(list remote branch)
496+
(user-error "Branch has no upstream")))
497+
(transient-args 'magit-stgit-rebase)))
498+
(when (and (called-interactively-p 'any)
499+
(y-or-n-p "Update remote first? "))
500+
(message "Updating remote...")
501+
(magit-run-git-async "remote" "update" remote)
502+
(message "Updating remote...done"))
503+
(magit-run-stgit "rebase" args (format "remotes/%s/%s" remote branch)))
499504

500505
(magit-define-popup magit-stgit-delete-popup
501506
"Popup console for StGit delete."
@@ -701,7 +706,7 @@ the To, Cc, and Bcc fields for all patches."
701706
:help "Refresh the contents of a patch in an StGit series"]
702707
["Repair" magit-stgit-repair
703708
:help "Repair StGit metadata if branch was modified with git commands"]
704-
["Rebase series" magit-stgit-rebase-popup
709+
["Rebase series" magit-stgit-rebase
705710
:help "Rebase an StGit patch series"]
706711
"---"
707712
["Undo the last operation" magit-stgit-undo-popup

0 commit comments

Comments
 (0)