Repository navigation
fix(switch): suggest a dev.azure.com URL when the Azure remote is SSH - #4364
Merged
Merged
Conversation
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`.
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.
For a user whose Azure DevOps remote is SSH (
git@ssh.dev.azure.com:v3/...),wt switch pr:Ncould suggest adding a remote athttps://ssh.dev.azure.com/..., which isn't a web host. This PR makes the suggestion usehttps://dev.azure.com/....Path: when
az repos pr showreturns norepository.webUrl,fetch_pr_infofalls back to the(host, org)thatdetect_azure_targetreads 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_urlbuilds the "Add the remote" hint on that SSH host. The PR link printed just above it was already correct, becausepr_web_urlmaps every non-visualstudio host todev.azure.com.Fix:
detect_azure_targetnow returns a web host, the same shapeparse_web_urlreturns from the response:*.visualstudio.comkeeps its hostname, and every other Azure remote (onlydev.azure.comandssh.dev.azure.comare detected as Azure by host) maps todev.azure.com.az_org_urlalready treated both cloud hosts the same, so the--orgargument doesn't change.I didn't put the normalization in
fork_remote_url.GitRemoteUrl::repo_infopasses a custom on-prem host through it when[forge].platformforces Azure DevOps, and rewriting that host todev.azure.comwould break Azure DevOps Server.Test:
test_switch_pr_azure_ssh_remote_suggests_web_hostuses an SSH origin, a response withoutwebUrl, and a PR in a sibling repository. Onmainthe snapshot showsgit remote add upstream https://ssh.dev.azure.com/myorg/myproject/_git/other-repo; with the fix it showshttps://dev.azure.com/.... All 28 Azure integration tests and the Azure unit tests pass locally.