The Guix project recently migrated 1 all of their repositories to Codeberg 2. In order to facilitate making easy pull requests from the comfort of Magit and Emacs, I've adapted the following Emacs Lisp snippet, based on work by sarg 3:
(transient-define-suffix magit-push-current-agit (source target args) :if #'magit-get-current-branch :description (lambda () (concat (magit-push--upstream-description) " (agit)")) (interactive (let ((source (or (magit-get-current-branch) (user-error "No branch is checked out")))) (list source (magit-get-upstream-branch source) (magit-push-arguments)))) (magit-push-refspecs (magit-get "branch" source "remote") (concat "HEAD" ":refs/for/" (magit-get-local-upstream-branch source) "/" source) `(,@args ,@(if (or (member "--force" args) (member "--force-with-lease" args)) '("-o" "force-push=true") '())))) (transient-insert-suffix 'magit-push "p" '("a" magit-push-current-agit))
This allows me to create a local branch from e.g. the upstream
javascript-team branch, make some local changes, and open a Pull
Request targeting the upstream javascript-team branch with a quick
P a from my magit window.
Some missing features include: