Skip to content

fix(switch): match encoded Azure project paths - #3204

Merged
max-sixty merged 1 commit into
max-sixty:mainfrom
jonasherfort:fix/azure-project-space-pr-switch
Jun 24, 2026
Merged

fix(switch): match encoded Azure project paths#3204
max-sixty merged 1 commit into
max-sixty:mainfrom
jonasherfort:fix/azure-project-space-pr-switch

Conversation

@jonasherfort

@jonasherfort jonasherfort commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #3203.

Azure DevOps returns decoded project names from az repos pr show, while Git remotes store project path segments URL-encoded. Canonicalize Azure path segments before comparing remotes and constructing Azure URLs, so wt switch pr:N works for projects like project with spaces.

Added an integration regression covering an encoded Azure project path with a decoded Azure API project name.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Azure DevOps remote matching for wt switch pr:N when Azure returns a decoded project name (e.g. project with spaces) but the git remote URL stores the project path segment URL-encoded (e.g. project%20with%20spaces). It does this by canonicalizing URL path segments (decode → re-encode) before comparing and when constructing Azure URLs, and adds an integration regression test.

Changes:

  • Add URL path segment canonicalization helpers (canonical_url_path_segment, url_path_segments_eq) to normalize encoded vs decoded Azure path segments.
  • Use canonicalized segment comparison when selecting an Azure remote (project + repo) from configured git remotes.
  • Canonicalize Azure URL path segments when constructing fork/PR/build web URLs, and add an integration snapshot covering a space-containing Azure project name.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/git/url.rs Adds canonicalization + equality helpers for URL path segments (decode then encode) to normalize encoded/decoded forms.
src/git/repository/remotes.rs Uses canonicalized segment comparison when matching Azure project/repo against configured remotes.
src/git/remote_ref/azure.rs Canonicalizes organization/project/repo segments when constructing Azure remote + web URLs so URLs are consistently encoded.
src/git/mod.rs Re-exports the new URL helper functions for use across git modules.
tests/integration_tests/switch.rs Adds an integration test for wt switch pr:101 where the remote has an encoded project segment but the Azure API project name is decoded.
tests/snapshots/integration__integration_tests__switch__switch_pr_azure_project_name_with_spaces.snap Adds the regression snapshot asserting successful switch and the expected (encoded) Azure PR web URL in output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jonasherfort
jonasherfort force-pushed the fix/azure-project-space-pr-switch branch 3 times, most recently from ae1d834 to ad7b6c3 Compare June 24, 2026 08:38
@jonasherfort
jonasherfort force-pushed the fix/azure-project-space-pr-switch branch from 32f1c53 to 8a31d9e Compare June 24, 2026 08:40
@max-sixty
max-sixty merged commit f246751 into max-sixty:main Jun 24, 2026
35 checks passed
@max-sixty

Copy link
Copy Markdown
Owner

thanks @jonasherfort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure DevOps pr: switch fails when project name contains spaces

4 participants