Fix pr checkout for agit-based workflows in forgejo#117
Merged
Conversation
I encountered this error: ``` $ git cd https://codeberg.org/forgejo/website/pulls/926/files fatal: couldn't find remote ref refs/heads/refs/pull/926/head Error: fetching origin/refs/pull/926/head: exit status 128 ``` It turned out that the gitea module returns a full git ref `refs/pull/123` for PRs that don't have a real git branch to check out to. This case wasn't properly handled by the generic checkout code.
This reverts commit c8a1070.
andrew
approved these changes
Jun 8, 2026
andrew
left a comment
Contributor
There was a problem hiding this comment.
LGTM — clean separation between bare branch names and full refs, with the local-branch fallback handling the AGit case well. Routing fork PRs with pull refs through the same-repo path is the right call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When checking out forgejo PRs that do not have a real head branch (using
agit-based workflow),
head.Refis of the formrefs/pull/123/head. This isnot a real branch name and using it for PR checkout will break right now,
because the generic code in
internal/cliwill try to wrap it in anothergeneric ref,
refs/heads/refs/pull/....Example PR: https://codeberg.org/forgejo/website/pulls/926
Other forges don't have this concept, and it only breaks on some PRs in
forgejo.
We could handle this case by checking
Reffor a prefix within the CLI, butnow we're handling agit-specificities in code that is supposed to be generic.
Refis currently documented as "branch name". I've changed the doc to pointout that it can be a full ref, and that downstream code just has to handle
that.
If we want to keep
Refbeing just a branch name, the other option is to makeit optional and add another optional field
PullRefthat contains a full ref.This is explored in a commit in this PR, but ultimately reverted since it only
made the model more technically correct with no actual gained capability.