Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Closes magit#518.
  • Loading branch information
DamienCassou committed Oct 24, 2022
1 parent ce212f8 commit 3f6639a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Takes the pull-request as only argument and must return a directory."
:group 'forge
:type 'function)

(defcustom forge-checkout-reset-existing-branch
nil
"srtsrt"
:package-version '(forge . "0.4.0")
:group 'forge
:type '(choice (const :tag "Reset the branch as it exists remotely" t)
(const :tag "Ask the user if the branch should be left intact" ask)
(const :tag "Keep the branch intact" nil)))

;;; Dispatch

;;;###autoload (autoload 'forge-dispatch "forge-commands" nil t)
Expand Down Expand Up @@ -736,17 +745,24 @@ because the source branch has been deleted"))

;;;###autoload
(defun forge-checkout-pullreq (pullreq)
"Create, configure and checkout a new branch from a pull-request.
Please see the manual for more information."
"Checkout the branch of a PULLREQ."
(interactive (list (forge-read-pullreq "Checkout pull request" t)))
(let ((pullreq (forge-get-pullreq pullreq)))
(when-let* (pullreq
(pullreq (forge-get-pullreq pullreq))
(branch (or (if (not (eq (oref pullreq state) 'open))
(magit-ref-p (format "refs/pullreqs/%s"
(oref pullreq number)))
(forge--pullreq-branch-active pullreq))
(forge--pullreq-branch-internal pullreq))))
(magit-checkout
(or (if (not (eq (oref pullreq state) 'open))
(magit-ref-p (format "refs/pullreqs/%s"
(oref pullreq number)))
(forge--pullreq-branch-active pullreq))
(if (or
(not (magit-branch-p branch))
(eq forge-checkout-reset-existing-branch t)
(and (eq forge-checkout-reset-existing-branch 'ask)
(y-or-n-p (format "Reset %s?" branch))))
(let ((magit-inhibit-refresh t))
(forge-branch-pullreq pullreq))))))
(forge-branch-pullreq pullreq))
branch))))

;;;###autoload
(defun forge-checkout-worktree (path pullreq)
Expand Down

0 comments on commit 3f6639a

Please sign in to comment.