Function: forge--setup-pullreq-remote
forge--setup-pullreq-remote is a byte-compiled function defined in
forge-commands.el.
Signature
(forge--setup-pullreq-remote PULLREQ)
Source Code
;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-commands.el
(defun forge--setup-pullreq-remote (pullreq)
(let* ((pr-remote (oref pullreq head-user))
(pr-branch (oref pullreq head-ref))
(repo (forge-get-repository pullreq))
(host (oref repo githost))
(user (oref pullreq head-user))
(fork (oref pullreq head-repo)))
(if (magit-remote-p pr-remote)
(let ((url (magit-git-string "remote" "get-url" pr-remote))
(fetch (magit-get-all "remote" pr-remote "fetch")))
(unless (equal (forge--split-forge-url url)
(list host user (substring fork (1+ (length user)))))
(user-error "Remote `%s' already exists but does not point to %s"
pr-remote url))
(unless (or (member (format "+refs/heads/*:refs/remotes/%s/*"
pr-remote)
fetch)
(member (format "+refs/heads/%s:refs/remotes/%s/%s"
pr-branch pr-remote pr-branch)
fetch))
(magit-git "remote" "set-branches" "--add" pr-remote pr-branch)
(magit-git "fetch" pr-remote)))
(let ((url (magit-git-string "remote" "get-url" (oref repo remote))))
(magit-git
"remote" "add" "-f" "--no-tags"
"-t" pr-branch pr-remote
(cond ((or (string-prefix-p "git@" url)
(string-prefix-p "ssh://git@" url))
(format "git@%s:%s.git" host fork))
((string-prefix-p "https://" url)
(format "https://%s/%s.git" host fork))
((string-prefix-p "git://" url)
(format "git://%s/%s.git" host fork))
((string-prefix-p "http://" url)
(format "http://%s/%s.git" host fork))
((error "%s has an unexpected format" url))))))))