public void FullValidation_EnterpriseNewHttps() { // 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://bitbucket.domain.com/scm/test-org/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> <ItemGroup> <SourceLinkBitbucketGitHost Include=""bitbucket.domain.com"" EnterpriseEdition=""true"" Version=""4.7""/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { NuGetPackageFolders, ProjectSourceRoot, $"https://bitbucket.domain.com/projects/test-org/repos/{repoName}/raw/*?at={commitSha}", s_relativeSourceLinkJsonPath, $"https://bitbucket.domain.com/scm/test-org/{repoName}", $"https://bitbucket.domain.com/scm/test-org/{repoName}" }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://bitbucket.domain.com/projects/test-org/repos/{repoName}/raw/*?at={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://bitbucket.domain.com/scm/test-org/{repoName}"); }
public void FullValidation_Ssh() { // 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://tfs.噸.local:22/tfs/DefaultCollection/project/_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> <ItemGroup> <SourceLinkAzureDevOpsServerGitHost Include=""tfs.噸.local"" VirtualDirectory=""tfs""/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { NuGetPackageFolders, ProjectSourceRoot, $"https://tfs.噸.local/tfs/DefaultCollection/project/_apis/git/repositories/{repoName}/items?api-version=1.0&versionType=commit&version={commitSha}&path=/*", s_relativeSourceLinkJsonPath, $"https://tfs.噸.local/tfs/DefaultCollection/project/_git/{repoName}", $"https://tfs.噸.local/tfs/DefaultCollection/project/_git/{repoName}", }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://tfs.噸.local/tfs/DefaultCollection/project/_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://tfs.噸.local/tfs/DefaultCollection/project/_git/{repoName}"); }
public void FullValidation_Ssh() { // 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://git@噸.com/test-%72epo\u1234%24%2572%2F.git"; var repoName = "test-repo\u1234%24%2572%2F.git"; var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, repoUrl); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> <ItemGroup> <SourceLinkGitWebHost Include='噸.com' ContentUrl='https://噸.com/gitweb'/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { NuGetPackageFolders, ProjectSourceRoot, $"https://噸.com/gitweb/?p={repoName};a=blob_plain;hb={commitSha};f=*", s_relativeSourceLinkJsonPath, $"ssh://git@噸.com/{repoName}", $"ssh://git@噸.com/{repoName}" }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://噸.com/gitweb/?p={repoName};a=blob_plain;hb={commitSha};f=*""}}}}", 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: $"ssh://git@噸.com/{repoName}"); }
public void FullValidation_EnterpriseNewHttps_UrlWithPersonalToken() { var repoUrl = "https://user_name%40domain.com:[email protected]/scm/test-org/project1.git"; var repoName = "project1"; var repo = GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, repoUrl); var commitSha = repo.Head.Tip.Sha; VerifyValues( customProps: @" <PropertyGroup> <PublishRepositoryUrl>true</PublishRepositoryUrl> </PropertyGroup> <ItemGroup> <SourceLinkBitbucketGitHost Include=""bitbucket.domain.com"" EnterpriseEdition=""true"" Version=""4.7""/> </ItemGroup> ", customTargets: "", targets: new[] { "Build", "Pack" }, expressions: new[] { "@(SourceRoot)", "@(SourceRoot->'%(SourceLinkUrl)')", "$(SourceLink)", "$(PrivateRepositoryUrl)", "$(RepositoryUrl)" }, expectedResults: new[] { ProjectSourceRoot, $"https://bitbucket.domain.com/projects/test-org/repos/{repoName}/raw/*?at={commitSha}", s_relativeSourceLinkJsonPath, $"https://bitbucket.domain.com/scm/test-org/{repoName}.git", $"https://bitbucket.domain.com/scm/test-org/{repoName}.git" }); AssertEx.AreEqual( $@"{{""documents"":{{""{ProjectSourceRoot.Replace(@"\", @"\\")}*"":""https://bitbucket.domain.com/projects/test-org/repos/{repoName}/raw/*?at={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://bitbucket.domain.com/scm/test-org/{repoName}.git"); }
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 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}"); }