public void FullValidation_Https(string host) { // Test non - ascii characters and escapes in the URL. // Escaped URI reserved characters should remain escaped, non-reserved characters unescaped in the results. var repoUrl = $"https://test.{host}/test-org/_git/test-%72epo\u1234%24%2572%2F"; var repoName = "test-repo\u1234%24%2572%2F"; var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, repoUrl); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://test.{host}/test-org/_apis/git/repositories/{repoName}/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*", s_relativeSourceLinkJsonPath, $"https://test.{host}/test-org/_git/{repoName}", $"https://test.{host}/test-org/_git/{repoName}", }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://test.{host}/test-org/_apis/git/repositories/{repoName}/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*""}}}}", File.ReadAllText(Path.Combine(ProjectDir.Path, s_relativeSourceLinkJsonPath))); TestUtilities.ValidateAssemblyInformationalVersion( Path.Combine(ProjectDir.Path, s_relativeOutputFilePath), "1.0.0+" + commitSha); TestUtilities.ValidateNuSpecRepository( Path.Combine(ProjectDir.Path, s_relativePackagePath), type: "git", commit: commitSha, url: $"https://test.{host}/test-org/_git/{repoName}"); }
public void FullValidation_Ssh() { var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "[email protected]:test-org/test-repo"); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> <ItemGroup> <SourceLinkBitBucketGitHost Include='cloudbitbucket.com'/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://cloudbitbucket.com/test-org/test-repo/raw/{commitSha}/*", s_relativeSourceLinkJsonPath, "https://cloudbitbucket.com/test-org/test-repo", "https://cloudbitbucket.com/test-org/test-repo" }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://cloudbitbucket.com/test-org/test-repo/raw/{commitSha}/*""}}}}", File.ReadAllText(Path.Combine(ProjectDir.Path, s_relativeSourceLinkJsonPath))); TestUtilities.ValidateAssemblyInformationalVersion( Path.Combine(ProjectDir.Path, s_relativeOutputFilePath), "1.0.0+" + commitSha); TestUtilities.ValidateNuSpecRepository( Path.Combine(ProjectDir.Path, s_relativePackagePath), type: "git", commit: commitSha, url: "https://cloudbitbucket.com/test-org/test-repo"); }
public void FullValidation_Ssh() { var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "ssh://tfs.mydomain.local:22/tfs/DefaultCollection/project/_ssh/MyProject"); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> <ItemGroup> <SourceLinkTfsGitHost Include=""tfs.mydomain.local"" VirtualDirectory=""tfs""/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://tfs.mydomain.local/tfs/DefaultCollection/project/_apis/git/repositories/MyProject/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*", s_relativeSourceLinkJsonPath, "https://tfs.mydomain.local/tfs/DefaultCollection/project/_git/MyProject", "https://tfs.mydomain.local/tfs/DefaultCollection/project/_git/MyProject", }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://tfs.mydomain.local/tfs/DefaultCollection/project/_apis/git/repositories/MyProject/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*""}}}}", File.ReadAllText(Path.Combine(ProjectDir.Path, s_relativeSourceLinkJsonPath))); TestUtilities.ValidateAssemblyInformationalVersion( Path.Combine(ProjectDir.Path, s_relativeOutputFilePath), "1.0.0+" + commitSha); TestUtilities.ValidateNuSpecRepository( Path.Combine(ProjectDir.Path, s_relativePackagePath), type: "git", commit: commitSha, url: "https://tfs.mydomain.local/tfs/DefaultCollection/project/_git/MyProject"); }
public void FullValidation_Ssh(string host) { var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, $"ssh://test@vs-ssh.{host}:22/test-org/_ssh/test-repo"); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://test.{host}/test-org/_apis/git/repositories/test-repo/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*", s_relativeSourceLinkJsonPath, $"https://test.{host}/test-org/_git/test-repo", $"https://test.{host}/test-org/_git/test-repo", }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://test.{host}/test-org/_apis/git/repositories/test-repo/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*""}}}}", File.ReadAllText(Path.Combine(ProjectDir.Path, s_relativeSourceLinkJsonPath))); TestUtilities.ValidateAssemblyInformationalVersion( Path.Combine(ProjectDir.Path, s_relativeOutputFilePath), "1.0.0+" + commitSha); TestUtilities.ValidateNuSpecRepository( Path.Combine(ProjectDir.Path, s_relativePackagePath), type: "git", commit: commitSha, url: $"https://test.{host}/test-org/_git/test-repo"); }
public void GenerateSourceLinkFileTarget_EnableSourceLinkCondition() { GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "http://github.com/test-org/test-repo"); VerifyValues( customProps: @" <PropertyGroup> <Test_DefaultEnableSourceControlManagerQueries>$(EnableSourceControlManagerQueries)</Test_DefaultEnableSourceControlManagerQueries> <Test_DefaultEnableSourceLink>$(EnableSourceLink)</Test_DefaultEnableSourceLink> </PropertyGroup> ", customTargets: @" <Target Name=""Test_SetEnableSourceLink"" BeforeTargets=""InitializeSourceControlInformation""> <PropertyGroup> <EnableSourceLink>false</EnableSourceLink> </PropertyGroup> </Target> ", targets: new[] { "Build" }, expressions: new[] { "@(SourceRoot)", "$(Test_DefaultEnableSourceControlManagerQueries)", "$(Test_DefaultEnableSourceLink)", "$(SourceLink)" }, expectedResults: new[] { NuGetPackageFolders, ProjectSourceRoot, "true", "true", "" }); }
public void Host_VisualStudio(string host) { // Test non - ascii characters and escapes in the URL. // Escaped URI reserved characters should remain escaped, non-reserved characters unescaped in the results. var repoUrl = $"https://test.{host}/test-org/_git/test-%72epo\u1234%24%2572%2F"; var repoName = "test-repo\u1234%24%2572%2F"; var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, repoUrl); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { NuGetPackageFolders, ProjectSourceRoot, $"https://test.{host}/test-org/_apis/git/repositories/{repoName}/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*", s_relativeSourceLinkJsonPath, $"https://test.{host}/test-org/_git/{repoName}", $"https://test.{host}/test-org/_git/{repoName}", }); }
public void CustomTranslation() { // Test non-ascii characters and escapes in the URL. // Escaped URI reserved characters should remain escaped, non-reserved characters unescaped in the results. var repoUrl = "ssh://[email protected]:22/test-org/_ssh/test-%72epo\u1234%24%2572%2F"; var repoName = "test-repo\u1234%24%2572%2F"; var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, repoUrl); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> ", customTargets: @" <Target Name=""TranslateVstsToGitHub"" DependsOnTargets=""$(SourceControlManagerUrlTranslationTargets)"" BeforeTargets=""SourceControlManagerPublishTranslatedUrls""> <PropertyGroup> <_Pattern>https://([^.]+)[.]visualstudio.com/([^/]+)/_git/([^/]+)</_Pattern> <_Replacement>https://github.com/$2/$3</_Replacement> </PropertyGroup> <PropertyGroup> <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_Pattern), $(_Replacement)))</ScmRepositoryUrl> </PropertyGroup> <ItemGroup> <SourceRoot Update=""@(SourceRoot)""> <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_Pattern), $(_Replacement)))</ScmRepositoryUrl> </SourceRoot> </ItemGroup> </Target> ", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://raw.githubusercontent.com/test-org/{repoName}/{commitSha}/*", s_relativeSourceLinkJsonPath, $"https://github.com/test-org/{repoName}", $"https://github.com/test-org/{repoName}", }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://raw.githubusercontent.com/test-org/{repoName}/{commitSha}/*""}}}}", File.ReadAllText(Path.Combine(ProjectDir.Path, s_relativeSourceLinkJsonPath))); TestUtilities.ValidateAssemblyInformationalVersion( Path.Combine(ProjectDir.Path, s_relativeOutputFilePath), "1.0.0+" + commitSha); TestUtilities.ValidateNuSpecRepository( Path.Combine(ProjectDir.Path, s_relativePackagePath), type: "git", commit: commitSha, url: $"https://github.com/test-org/{repoName}"); }