Skip to content

fix(switch): suggest a dev.azure.com URL when the Azure remote is SSH - #4364

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-37188565926-azure-fork-url
Oct 4, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-37188565926-azure-fork-url

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

For a user whose Azure DevOps remote is SSH (git@ssh.dev.azure.com:v3/...), wt switch pr:N could suggest adding a remote at https://ssh.dev.azure.com/..., which isn't a web host. This PR makes the suggestion use https://dev.azure.com/....

Path: when az repos pr show returns no repository.webUrl, fetch_pr_info falls back to the (host, org) that detect_azure_target reads from local remotes. Before this change it returned the remote's raw host. If the PR then belongs to a repository with no local remote (PR ids are org-scoped, so another repo in the org qualifies), azure::fork_remote_url builds the "Add the remote" hint on that SSH host. The PR link printed just above it was already correct, because pr_web_url maps every non-visualstudio host to dev.azure.com.

Fix: detect_azure_target now returns a web host, the same shape parse_web_url returns from the response: *.visualstudio.com keeps its hostname, and every other Azure remote (only dev.azure.com and ssh.dev.azure.com are detected as Azure by host) maps to dev.azure.com. az_org_url already treated both cloud hosts the same, so the --org argument doesn't change.

I didn't put the normalization in fork_remote_url. GitRemoteUrl::repo_info passes a custom on-prem host through it when [forge].platform forces Azure DevOps, and rewriting that host to dev.azure.com would break Azure DevOps Server.

Test: test_switch_pr_azure_ssh_remote_suggests_web_host uses an SSH origin, a response without webUrl, and a PR in a sibling repository. On main the snapshot shows git remote add upstream https://ssh.dev.azure.com/myorg/myproject/_git/other-repo; with the fix it shows https://dev.azure.com/.... All 28 Azure integration tests and the Azure unit tests pass locally.

When `az repos pr show` returns no `repository.webUrl`, `fetch_pr_info`
falls back to the host and org detected from local remotes. For an
`ssh.dev.azure.com` remote that host was the SSH host, so the
"No remote found" hint for a PR in another repository of the org
suggested `https://ssh.dev.azure.com/...`, which isn't a web host.

`detect_azure_target` now reports a web host, matching what
`parse_web_url` returns from the response: `*.visualstudio.com` keeps its
hostname and every other Azure remote maps to `dev.azure.com`.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Oct 4, 2026
@max-sixty
max-sixty merged commit 7ea4346 into main Oct 4, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-37188565926-azure-fork-url branch October 4, 2026 09:20
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