Skip to content

Commit d50e585

Browse files
authored
Support Azure DevOps vs-ssh.visualstudio.com SSH remotes as hosting provider (#4822)
**PR Description** This PR adds support for parsing **legacy Azure DevOps SSH remotes** that use the `vs-ssh.visualstudio.com` host, which is still common in older repositories or corporate setups. This PR fixes issue #2667. Previously, even if users mapped this host to the Azure DevOps provider via `configServiceDomains`, URL generation failed with: ``` Failed to parse repo information from url ``` because the Azure DevOps `ServiceDefinition` regex set did not include this SSH format. ### Changes - Added a new regex to `azdoServiceDef.regexStrings` to match: ``` [email protected]:v3/<org>/<project>/<repo> ``` - This allows `getRepoURLFromRemoteURL` to correctly extract `org`, `project`, and `repo` for these remotes. - Added a test case to `TestGetPullRequestURL` verifying that mapping `vs-ssh.visualstudio.com` → `azuredevops:dev.azure.com` produces the correct PR URL. ### Example With this config: ```yaml services: 'vs-ssh.visualstudio.com': 'azuredevops:dev.azure.com' ``` and remote: ``` [email protected]:v3/myorg/myproject/myrepo ``` `GetPullRequestURL("feature/new", "")` now returns: ``` https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew ``` ### Why - Many users still have remotes in this legacy format. - This change is **backward-compatible** and does not affect existing supported remotes. - It unblocks URL generation for PRs and commits without requiring users to change their remotes. - Fixes #2667
2 parents 0c0f53f + a44af06 commit d50e585

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/commands/hosting_service/definitions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var azdoServiceDef = ServiceDefinition{
4646
pullRequestURLIntoTargetBranch: "/pullrequestcreate?sourceRef={{.From}}&targetRef={{.To}}",
4747
commitURL: "/commit/{{.CommitHash}}",
4848
regexStrings: []string{
49+
`^.+@vs-ssh\.visualstudio\.com[:/](?:v3/)?(?P<org>[^/]+)/(?P<project>[^/]+)/(?P<repo>[^/]+?)(?:\.git)?$`,
4950
`^[email protected].*/(?P<org>.*)/(?P<project>.*)/(?P<repo>.*?)(?:\.git)?$`,
5051
`^https://.*@dev.azure.com/(?P<org>.*?)/(?P<project>.*?)/_git/(?P<repo>.*?)(?:\.git)?$`,
5152
`^https://.*/(?P<org>.*?)/(?P<project>.*?)/_git/(?P<repo>.*?)(?:\.git)?$`,

pkg/commands/hosting_service/hosting_service_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ func TestGetPullRequestURL(t *testing.T) {
223223
assert.Equal(t, "https://mycompany.azuredevops.com/collection/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew", url)
224224
},
225225
},
226+
{
227+
testName: "Opens a link to new pull request on Azure DevOps (legacy vs-ssh.visualstudio.com SSH) with mapping to dev.azure.com",
228+
from: "feature/new",
229+
remoteUrl: "[email protected]:v3/myorg/myproject/myrepo",
230+
configServiceDomains: map[string]string{
231+
"vs-ssh.visualstudio.com": "azuredevops:dev.azure.com",
232+
},
233+
test: func(url string, err error) {
234+
assert.NoError(t, err)
235+
assert.Equal(t, "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew", url)
236+
},
237+
},
226238
{
227239
testName: "Opens a link to new pull request on Bitbucket Server (SSH)",
228240
from: "feature/new",

0 commit comments

Comments
 (0)