diff --git a/docs/Implementation/AzureDevOpsServicesUrls.png b/docs/Implementation/AzureDevOpsServicesUrls.png index 59c83cf5..dad14989 100644 Binary files a/docs/Implementation/AzureDevOpsServicesUrls.png and b/docs/Implementation/AzureDevOpsServicesUrls.png differ diff --git a/src/Common/AzureDevOpsUrlParser.cs b/src/Common/AzureDevOpsUrlParser.cs index ff6cfc7b..a287fe8f 100644 --- a/src/Common/AzureDevOpsUrlParser.cs +++ b/src/Common/AzureDevOpsUrlParser.cs @@ -63,18 +63,16 @@ public static bool TryParseHostedHttp(string host, string relativeUrl, out strin return false; } - if (isVisualStudioHost) - { - projectPath = projectName ?? repositoryName; - } - else + projectPath = projectName ?? repositoryName; + + if (!isVisualStudioHost) { - if (projectName == null || teamName != null) + if (teamName != null) { return false; } - projectPath = account + "/" + projectName; + projectPath = account + "/" + projectPath; } return true; diff --git a/src/SourceLink.AzureRepos.Git.UnitTests/AzureDevOpsUrlParserHostedTests.cs b/src/SourceLink.AzureRepos.Git.UnitTests/AzureDevOpsUrlParserHostedTests.cs index 17e0bb37..cbdac190 100644 --- a/src/SourceLink.AzureRepos.Git.UnitTests/AzureDevOpsUrlParserHostedTests.cs +++ b/src/SourceLink.AzureRepos.Git.UnitTests/AzureDevOpsUrlParserHostedTests.cs @@ -49,6 +49,7 @@ public void TryParseHostedHttp_Error(string host, string relativeUrl) [InlineData("account.vsts.me", "/DefaultCollection/project/team/_git/_full/repo", "project", "repo")] [InlineData("account.vsts.me", "/DefaultCollection/project/team/_git/_optimized/repo", "project", "repo")] [InlineData("account.vsts.me", "/DefaultCollection/_git/repo", "repo", "repo")] + [InlineData("contoso.com", "/account/_git/repo", "account/repo", "repo")] [InlineData("contoso.com", "/account/project/_git/repo", "account/project", "repo")] [InlineData("contoso.com", "/account/project/_git/_full/repo", "account/project", "repo")] [InlineData("contoso.com", "/account/project/_git/_optimized/repo", "account/project", "repo")] diff --git a/src/SourceLink.AzureRepos.Git.UnitTests/GetSourceLinkUrlTests.cs b/src/SourceLink.AzureRepos.Git.UnitTests/GetSourceLinkUrlTests.cs index 4f6660fa..46854350 100644 --- a/src/SourceLink.AzureRepos.Git.UnitTests/GetSourceLinkUrlTests.cs +++ b/src/SourceLink.AzureRepos.Git.UnitTests/GetSourceLinkUrlTests.cs @@ -80,7 +80,8 @@ public void BadUrl(string domainAndAccount, string host) [Theory] [InlineData("account.visualstudio.com", "visualstudio.com")] [InlineData("account.vsts.me", "vsts.me")] - public void RepoOnly_VisualStudioHost(string domainAndAccount, string host) + [InlineData("contoso.com/account", "contoso.com")] + public void RepoOnly(string domainAndAccount, string host) { var engine = new MockEngine(); @@ -97,28 +98,6 @@ public void RepoOnly_VisualStudioHost(string domainAndAccount, string host) Assert.True(result); } - [Theory] - [InlineData("contoso.com/account", "contoso.com")] - public void RepoOnly_NonVisualStudioHost(string domainAndAccount, string host) - { - var engine = new MockEngine(); - - var task = new GetSourceLinkUrl() - { - BuildEngine = engine, - SourceRoot = new MockItem("/src/", KVP("RepositoryUrl", $"http://{domainAndAccount}/_git/repo"), KVP("SourceControl", "git"), KVP("RevisionId", "0123456789abcdefABCDEF000000000000000000")), - Hosts = new[] { new MockItem(host) } - }; - - bool result = task.Execute(); - - // ERROR : The value of SourceRoot.RepositoryUrl with identity '/src/' is invalid: 'http://account.visualstudio.com/_git/repo'"" - AssertEx.AssertEqualToleratingWhitespaceDifferences( - "ERROR : " + string.Format(CommonResources.ValueOfWithIdentityIsInvalid, "SourceRoot.RepositoryUrl", "/src/", $"http://{domainAndAccount}/_git/repo"), engine.Log); - - Assert.False(result); - } - [Theory] [InlineData("account.visualstudio.com", "visualstudio.com")] [InlineData("account.vsts.me", "vsts.me")]