worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Azure DevOps: repo.forge gives a wrong project for 3 forms of remote

Open owpac opened this issue 3 weeks ago • 1 comments

The friction

wt list --format json (wt 0.81.0) gives a wrong project (and a wrong url) in repo.forge for 3 valid forms of remote of Azure DevOps. A tool that reads this JSON then asks for the wrong project. The CI column of worktrunk can have the same problem: I could not test it, because az is not installed on the test machine.

Remote repo.forge now Expected
https://myorg.visualstudio.com/DefaultCollection/My%20Project/_git/my-repo url https://myorg.visualstudio.com/DefaultCollection/_git/my-repo, project DefaultCollection project My%20Project
[email protected]:v3/myorg/My%20Project/my-repo (the old ssh host) url https://vs-ssh.visualstudio.com/v3/_git/my-repo, host vs-ssh.visualstudio.com, owner vs-ssh, project v3 host myorg.visualstudio.com, owner myorg, project My%20Project
https://dev.azure.com/myorg/_git/my-repo (no project in the path) url https://dev.azure.com/myorg/_git/_git/my-repo, project _git project my-repo

Azure DevOps accepts the short form of the last row for the default repository of a project: the project has the name of the repository.

The forms https://dev.azure.com/<org>/<project>/_git/<repo> and [email protected]:v3/<org>/<project>/<repo> give the correct values.

To reproduce

git init demo && cd demo
git commit --allow-empty -m start
git remote add origin https://myorg.visualstudio.com/DefaultCollection/My%20Project/_git/my-repo
wt list --format json | jq -c .repo.forge

A note on the encoding

project and name keep the percent-encoding of the URL: My%20Project, my%20repo. The docs call project the "Azure DevOps project name". If this encoding is intended, one sentence in the docs would help a tool that reads the JSON.

Context

herdr-worktrunk reads repo.forge to ask Azure DevOps for the pull requests of each worktree, with az. For Azure DevOps, it now reads the organization, the project and the repository from the remote itself.

owpac avatar Nov 10 '26 11:11 owpac

I reproduced all three, and #4764 fixes them. The Azure org and project were read from fixed positions in the remote path. That broke on the DefaultCollection/ prefix, on the legacy vs-ssh.visualstudio.com host (where the org appears only in the path), and on the short {org}/_git/{repo} form. The fix resolves all three to the values in your table. The CI column shared the bug, because it reads the same accessors: it would have asked az for project DefaultCollection / v3 / _git, and for the legacy SSH host it also built the org URL from vs-ssh. The fix covers that path too, but I haven't verified it against a real az, since CI has no Azure login.

On the encoding: project and name still carry the URL's percent-encoding, and the PR doesn't change that. Whether the JSON should decode them or the docs should say they stay encoded is a maintainer call. Until then, decode them on your side before passing them to az.

The PR's CI is running, and the PR needs a maintainer to merge it.

worktrunk-bot avatar Nov 10 '26 11:11 worktrunk-bot