示例#1
0
        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()));
        }