protected override string BuildSourceLinkUrl(Uri contentUri, Uri gitUri, string relativeUrl, string revisionId, ITaskItem hostItem) { if (!AzureDevOpsUrlParser.TryParseHostedHttp(gitUri.GetHost(), relativeUrl, out var projectPath, out var repositoryName)) { Log.LogError(CommonResources.ValueOfWithIdentityIsInvalid, Names.SourceRoot.RepositoryUrlFullName, SourceRoot.ItemSpec, gitUri); return(null); } return (UriUtilities.Combine( UriUtilities.Combine(contentUri.ToString(), projectPath), $"_apis/git/repositories/{repositoryName}/items") + $"?api-version=1.0&versionType=commit&version={revisionId}&path=/*"); }
public void TryParseHostedHttp_Success(string host, string relativeUrl, string repositoryPath, string repositoryName) { Assert.True(AzureDevOpsUrlParser.TryParseHostedHttp(host, relativeUrl, out var actualRepositoryPath, out var actualRepositoryName)); Assert.Equal(repositoryPath, actualRepositoryPath); Assert.Equal(repositoryName, actualRepositoryName); }
public void TryParseHostedHttp_Error(string host, string relativeUrl) { Assert.False(AzureDevOpsUrlParser.TryParseHostedHttp(host, relativeUrl, out _, out _)); }