public virtual void TestCloneRepositoryOnlyOneBranch() { FilePath directory = CreateTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.CloneRepository(); command.SetBranch("refs/heads/master"); command.SetBranchesToClone(Collections.SingletonList("refs/heads/master")); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); Git git2 = command.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/master" ); NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master", AllRefNames(git2.BranchList ().SetListMode(ListBranchCommand.ListMode.REMOTE).Call())); // Same thing, but now test with bare repo directory = CreateTempDirectory("testCloneRepositoryWithBranch_bare"); command = Git.CloneRepository(); command.SetBranch("refs/heads/master"); command.SetBranchesToClone(Collections.SingletonList("refs/heads/master")); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); command.SetBare(true); git2 = command.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/master" ); NUnit.Framework.Assert.AreEqual("refs/heads/master", AllRefNames(git2.BranchList( ).SetListMode(ListBranchCommand.ListMode.ALL).Call())); }
public virtual void TestCloneRepositoryWithBranch() { try { FilePath directory = CreateTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.CloneRepository(); command.SetBranch("refs/heads/master"); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); Git git2 = command.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/master" ); NUnit.Framework.Assert.AreEqual("refs/heads/master, refs/remotes/origin/master, refs/remotes/origin/test" , AllRefNames(git2.BranchList().SetListMode(ListBranchCommand.ListMode.ALL).Call ())); // Same thing, but now without checkout directory = CreateTempDirectory("testCloneRepositoryWithBranch_bare"); command = Git.CloneRepository(); command.SetBranch("refs/heads/master"); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); command.SetNoCheckout(true); git2 = command.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/master" ); NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master, refs/remotes/origin/test" , AllRefNames(git2.BranchList().SetListMode(ListBranchCommand.ListMode.ALL).Call ())); // Same thing, but now test with bare repo directory = CreateTempDirectory("testCloneRepositoryWithBranch_bare"); command = Git.CloneRepository(); command.SetBranch("refs/heads/master"); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); command.SetBare(true); git2 = command.Call(); AddRepoToClose(git2.GetRepository()); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/master" ); NUnit.Framework.Assert.AreEqual("refs/heads/master, refs/heads/test", AllRefNames (git2.BranchList().SetListMode(ListBranchCommand.ListMode.ALL).Call())); } catch (Exception e) { NUnit.Framework.Assert.Fail(e.Message); } }
public virtual void TestCloneRepositoryWithBranch() { try { FilePath directory = CreateTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.CloneRepository(); command.SetBranch("refs/heads/test"); command.SetDirectory(directory); command.SetURI("file://" + git.GetRepository().WorkTree.GetPath()); Git git2 = command.Call(); NUnit.Framework.Assert.IsNotNull(git2); NUnit.Framework.Assert.AreEqual(git2.GetRepository().GetFullBranch(), "refs/heads/test" ); } catch (Exception e) { NUnit.Framework.Assert.Fail(e.Message); } }