Skip to content

fix(switch): accept Gitea PR source branches named pull/... - #4832

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-44031200023-gitea
Nov 17, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-44031200023-gitea

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

On a Gitea PR whose source branch name starts with pull/ or pulls/, such as pull/fix-login, wt switch pr:N failed with "has no usable source branch … may be in an invalid state". The branch is valid; the fix lets wt check it out.

The cause is is_real_branch_name in src/git/remote_ref/gitea.rs. It rejected every candidate with either prefix so it could filter out the pulls/<n>/head tracking ref Gitea reports for a deleted source branch, and that also caught real branches. It now rejects only the tracking-ref shape: pull/ or pulls/, then a number, then /head. Fully qualified refs/... values and placeholders with whitespace are still rejected as before. The failing path is remote_ref::fetch_pr_info → gitea::fetch_pr_info → extract_source_branch_from_parts.

The new unit test test_extract_source_branch_accepts_branch_named_pull failed before the change and passes after it. The existing tests for placeholders and deleted branches still pass. Found by the nightly survey.

is_real_branch_name rejected any candidate starting with pull/ or pulls/
to filter Gitea's pulls/<n>/head tracking refs, so wt switch pr:N on a
same-repo PR from a branch like pull/fix-login bailed with "no usable
source branch". Match only the <n>/head tracking-ref shape.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Nov 17, 2026
@max-sixty
max-sixty merged commit cd257cb into main Nov 17, 2026
36 of 45 checks passed
@max-sixty
max-sixty deleted the nightly/clean-44031200023-gitea branch November 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants