Пример #1
0
        public void Given_repo_When_getting_HeadRef_1_Then_return_parent_of_HEAD()
        {
            var git          = repoBuilder.Build2Files3Commits();
            var parentOfHead = git.Hd.Commits[git.Hd.Head.GetId(git.Hd)].Parents.First();

            Assert.Equal(parentOfHead, git.HeadRef(1));
        }
Пример #2
0
        public void CommitWhenHeadless()
        {
            repoBuilder = new RepoBuilder(@"c:\temp\");
            var git = repoBuilder.Build2Files3Commits();

            git.Checkout(git.HeadRef(1));
            repoBuilder.AddFile("newfile", "dslfk");

            var id = git.Commit("headless commit", "a", new DateTime(2010, 11, 12), git.ScanFileSystem());

            Assert.Equal("48a24325bf46e633d025dbb88167e0ba867213d9c61f7ab7cb24b2af15450c00", id.ToString());
        }
Пример #3
0
        public void CommitWhenHeadless()
        {
            repoBuilder = new RepoBuilder(@"c:\temp\");
            var git = repoBuilder.Build2Files3Commits();

            git.Branches.Checkout(git.HeadRef(1));
            repoBuilder.AddFile("newfile", "dslfk");

            var id = git.Commit("headless commit", "a", new DateTime(2010, 11, 12));

            Assert.Equal("f4982f442bf946c3678bc68761a1da953ff1f61020311d1802167288b5514087", id.ToString());
        }
Пример #4
0
        public void When_pushing_Then_push_nodes_and_update_branchpointer_on_server()
        {
            var remoteGit    = new RepoBuilder().BuildEmptyRepo();
            var gitServer    = SpinUpServer(remoteGit, 18083);
            var localbuilder = new RepoBuilder();
            var localGit     = localbuilder.Build2Files3Commits();

            localbuilder.AddLocalHostRemote(18083);

            Branch branch  = localGit.Hd.Branches["master"];
            var    commits = localGit.GetReachableNodes(branch.Tip).ToArray();

            new GitNetworkClient().PushBranch(localGit.Hd.Remotes.First(), "master", branch, null, commits);

            Assert.Equal(@"Log for master
* d2c19da - Add a2 (2017/03/03 03:03:03) <kasper> 
* 5b65531 - Add b (2017/02/02 02:02:02) <kasper> 
* 27047ec - Add a (2017/01/01 01:01:01) <kasper> 
", remoteGit.Log());
            gitServer.Abort();
        }
Пример #5
0
        public void When_pushing_Then_push_nodes_and_update_branchpointer_on_server()
        {
            var remoteGit    = new RepoBuilder().BuildEmptyRepo();
            var gitServer    = SpinUpServer(remoteGit, 18083);
            var localbuilder = new RepoBuilder();
            var localGit     = localbuilder.Build2Files3Commits();

            localbuilder.AddLocalHostRemote(18083);

            Branch branch  = localGit.Hd.Branches["master"];
            var    commits = localGit.GetReachableNodes(branch.Tip).ToArray();

            new GitNetworkClient().PushBranch(localGit.Hd.Remotes.First(), "master", branch, null, commits);

            var actual = remoteGit.Log();

            Assert.Equal(@"
Log for master
* e7ea1966e7cb9b96e956a53d4a7042aa4dcc69720363dd928087af50a8c26b32 - Add a2 (2017/03/03 03:03:03) <kasper> 
* ed0ea7ea22cbaf8b34ee711974568d42853aff967fdb8c21fac93788d8e8e954 - Add b (2017/02/02 02:02:02) <kasper> 
* f0800442b12313bbac440b9ae0aef5b2c1978c95e8ccaf4197d6816bd29bf673 - Add a (2017/01/01 01:01:01) <kasper> 
", actual);
            gitServer.Abort();
        }