Repository navigation
fix(switch): handle fork branch conflicts on GitLab and Azure DevOps - #4542
Conversation
The `wt switch` help said a local branch of the same name tracking something else "requires renaming first". That holds only for GitLab and Azure DevOps MRs. For GitHub and Gitea PRs, `resolve_fork_ref` falls back to an `<owner>/<branch>` local branch, which is fetch-only and can't push to the fork (it warns "Push to fork is not supported with prefixed branches"). Correct the sentence in place and regenerate the docs mirrors and help snapshot.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Azure DevOps fork changes are pull requests, not MRs: ForgeKind::ref_type maps Self::GitHub | Self::Gitea | Self::AzureDevOps => RefType::Pr, so wt shows PR #N and takes pr:<number>. Calling one an "Azure DevOps MR" points readers at the wrong shortcut. I'll push this wording to the source line and its four mirrors.
|
why do we have different behavior?? should we fix that |
|
It's history, not a deliberate split. #779 added the Neither forge is missing the information:
I'd fix it: GitLab with the same |
|
yes, please fix |
worktrunk-bot
left a comment
There was a problem hiding this comment.
GitLab's prefixed checkout still fails for valid SSH clone URLs with an explicit port; the inline change uses the existing URL parser.
|
Fixed in this PR. GitLab now prefixes a conflicting fork branch with the source project namespace (including nested groups), and Azure DevOps uses the fork repository name. These branches track the PR or MR ref and remain fetch-only. I updated the All checks passed on |
| let mut cmd = make_snapshot_cmd(&repo, "switch", &["pr:42"], None); | ||
| configure_mock_cli_env(&mut cmd, &mock_bin); | ||
| assert_cmd_snapshot!("switch_pr_azure_fork", cmd); | ||
| if missing_fork_url { |
There was a problem hiding this comment.
this does not look like a canonical way to handle tests??
There was a problem hiding this comment.
I changed the Azure fixture to build JSON values directly in 6fcd4dfd63afcf00256a8cc4d4461b7a9c19734e. The missing-URL case now sets both URL fields to null through Option values, without string replacement. All three Azure fork cases pass locally.
|
@worktrunk-bot my comment on
|
Each case gets its own test function over a shared setup helper, so no assertion branches on the case.
|
Split into three test functions in f66ec11: |
wt switchnow handles a fork PR or MR whose branch name is already used locally on GitLab and Azure DevOps, matching the existing GitHub and Gitea behavior. GitLab uses the source project's namespace as a prefix, including nested groups; Azure DevOps uses the fork repository name. The prefixed branch tracks the PR or MR ref and remains fetch-only, so it cannot push to the fork.The change also updates the
wt switchhelp and its generated documentation to describe the shared behavior. Integration tests cover GitLab conflicts with and without existing tracking, Azure DevOps conflicts, and the no-conflict Azure path. The prefixed-name unit tests, docs sync test, and help snapshots pass locally.