Skip to content

Commit b316dca

Browse files
author
Lluís Vilanova
committed
magit-stgit-refresh: Add popup
1 parent 7a3fe35 commit b316dca

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

magit-stgit.el

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@
8080
:group 'magit-stgit
8181
:type 'string)
8282

83-
(defcustom magit-stgit-refresh-stage-only t
84-
"Whether a patch is refreshed only with staged changes (or the worktree otherwise)."
85-
:group 'magit-stgit
86-
:type 'boolean)
87-
88-
(defcustom magit-stgit-refresh-ask-to-stage magit-commit-ask-to-stage
89-
"Whether to ask to stage everything when refreshing a patch and nothing is staged."
90-
:group 'magit-stgit
91-
:type 'boolean)
92-
9383
;;;; Faces
9484

9585
(defgroup magit-stgit-faces nil
@@ -269,7 +259,7 @@ Else, asks the user for a patch name."
269259
(?\r "Show" magit-stgit-show)
270260
(?a "Goto" magit-stgit-goto-popup)
271261
;;
272-
(?g "Refresh" magit-stgit-refresh)
262+
(?g "Refresh" magit-stgit-refresh-popup)
273263
(?r "Repair" magit-stgit-repair)
274264
(?R "Rebase" magit-stgit-rebase)
275265
;;
@@ -282,7 +272,7 @@ Else, asks the user for a patch name."
282272
(interactive)
283273
(magit-run-stgit "init"))
284274

285-
(defvar magit-stgit-new-filename-regexp ".stgit-new.txt")
275+
(defvar magit-stgit-new-filename-regexp ".stgit-\\(new\\|edit\\).txt")
286276

287277
(defun magit-stgit-new-check-buffer ()
288278
"Check if buffer is an StGit commit message."
@@ -381,24 +371,28 @@ Use ARGS to pass additional arguments."
381371
(interactive (-flatten (list (magit-stgit-uncommit-arguments))))
382372
(magit-run-stgit "uncommit" args))
383373

374+
(magit-define-popup magit-stgit-refresh-popup
375+
"Popup console for StGit refresh."
376+
'magit-popups
377+
:switches '((?u "Only update the current patch files" "--update")
378+
(?i "Refresh from index instead of worktree" "--index")
379+
(?F "Force refresh even if index is dirty" "--force")
380+
(?e "Edit the patch description" "--edit")
381+
(?s "Add \"Signed-off-by:\" line" "--sign")
382+
(?a "Add \"Acked-by:\" line" "--ack"))
383+
:actions '((?g "Refresh" magit-stgit-refresh))
384+
:default-action #'magit-stgit-refresh)
385+
384386
;;;###autoload
385-
(defun magit-stgit-refresh (&optional patch)
386-
"Refresh a StGit patch."
387-
(interactive
388-
(list (magit-stgit-read-patch "Refresh patch (default top)")))
389-
(let ((args '("refresh")))
390-
(when magit-stgit-refresh-stage-only
391-
(add-to-list 'args "-i" t)
392-
(unless (magit-anything-staged-p)
393-
(if magit-stgit-refresh-ask-to-stage
394-
(if (y-or-n-p "Nothing staged. Stage and refresh everything? ")
395-
(magit-run-git "add" "-u" ".")
396-
(user-error "Nothing staged"))
397-
(user-error "Nothing staged"))))
398-
(when patch
399-
(add-to-list 'args "-p" t)
400-
(add-to-list 'args patch t))
401-
(magit-run-stgit args)))
387+
(defun magit-stgit-refresh (&optional patch &rest args)
388+
"Refresh StGit patch PATCH.
389+
Use ARGS to pass additional arguments."
390+
(interactive (list (magit-stgit-read-patches nil nil t nil "Refresh patch (default top)")
391+
(magit-stgit-refresh-arguments)))
392+
(setq patch (nth 0 patch))
393+
(when patch
394+
(add-to-list 'args (format "--patch=%s" patch) t))
395+
(magit-run-stgit-async "refresh" args))
402396

403397
;;;###autoload
404398
(defun magit-stgit-repair ()

0 commit comments

Comments
 (0)