public void When_empty_repo_Then_log_returns_empty() { var repoBuilder = new RepoBuilder().EmptyRepo(); Assert.Equal(@"Log for master ", repoBuilder.Git.Log()); }
public void When_two_commits_on_master_and_one_on_feature_Then_log_both_branches() { var repoBuilder = new RepoBuilder(new Guid("186d2ac8-1e9c-4e86-b1ac-b18208adead4")) .EmptyRepo() .AddFile("a.txt", "some content"); repoBuilder.Git.Commit("Add a.txt", "kasper graversen", new DateTime(2018, 3, 1, 12, 22, 33)); repoBuilder.AddFile("a.txt", "changed a..."); repoBuilder.Git.Commit("Changed a.txt", "kasper graversen", new DateTime(2018, 3, 2, 13, 24, 34)); repoBuilder .NewBranch("feature/speed") .AddFile("a.txt", "speedup!") .Git.Commit("Speedup a.txt", "kasper graversen", new DateTime(2018, 4, 3, 15, 26, 37)); var actual = repoBuilder.Git.Log(); Assert.Equal(@" Log for master * dd3044753fdb212c9248da29005a6d4765e3bbe302efff96a9321bf8ea710b83 - Changed a.txt (2018/03/02 01:24:34) <kasper graversen> * 06cd57d8d2feececc9eb48adda4cea5b57482324267f1e9632c16079ac6d793e - Add a.txt (2018/03/01 12:22:33) <kasper graversen> Log for feature/speed * fafcd20734eda4c9849aea8cb831c87f225909e32686637c54d3896513ecfca0 - Speedup a.txt (2018/04/03 03:26:37) <kasper graversen> ", actual); }
public void Given_fresh_repo_When_getting_headinfo_Then_fail() { var git = new RepoBuilder(@"c:\temp\").BuildEmptyRepo(); Assert.Null(git.Hd.Head.GetId(git.Hd)); Assert.Equal("master", git.Hd.Head.Branch); }
public void Get_folders_and_files() { var repoBuilder = new RepoBuilder(@"c:\temp\"); var git = repoBuilder.BuildEmptyRepo(); repoBuilder.AddFile(@"FeatureVolvo\car.txt", "car"); repoBuilder.AddFile(@"FeatureGarden\tree.txt", "tree"); repoBuilder.AddFile(@"FeatureGarden\shovel.txt", "shovel"); repoBuilder.AddFile(@"FeatureGarden\Suburb\grass.txt", "grass"); repoBuilder.AddFile(@"FeatureGarden\Suburb\mover.txt", "mover"); var files = FileSystemScanFolder(git); Assert.Equal( @"tree 2 tree 3 FeatureGarden blob FeatureGarden\shovel.txt blob FeatureGarden\tree.txt tree 2 FeatureGarden\Suburb blob FeatureGarden\Suburb\grass.txt blob FeatureGarden\Suburb\mover.txt tree 1 FeatureVolvo blob FeatureVolvo\car.txt" , files); }
public void Visit() { var repoBuilder = new RepoBuilder(@"c:\temp\"); var git = repoBuilder.BuildEmptyRepo(); repoBuilder.AddFile(@"FeatureVolvo\car.txt", "car"); repoBuilder.AddFile(@"FeatureGarden\tree.txt", "tree"); repoBuilder.AddFile(@"FeatureGarden\shovel.txt", "shovel"); repoBuilder.AddFile(@"FeatureGarden\Suburb\grass.txt", "grass"); string buf = ""; git.FileSystemScanFolder(git.CodeFolder).Visit(x => { if (x is TreeTreeLine t) { buf += $"visittree {t.Path}\r\n"; } if (x is BlobTreeLine b) { buf += $"visitblob {b.Path}\r\n"; } }); Assert.Equal(@"visittree visittree FeatureGarden visitblob FeatureGarden\shovel.txt visitblob FeatureGarden\tree.txt visittree FeatureGarden\Suburb visitblob FeatureGarden\Suburb\grass.txt visittree FeatureVolvo visitblob FeatureVolvo\car.txt ", buf); }
public void Given_repo_When_committing_getting_headinfo_Then_return_info() { repoBuilder = new RepoBuilder(@"c:\temp\"); var firstId = repoBuilder.EmptyRepo().AddFile("a.txt").Commit(); Assert.Equal(firstId, repoBuilder.Git.Hd.Head.GetId(repoBuilder.Git.Hd)); Assert.Null(repoBuilder.Git.Hd.Head.Id); Assert.Equal("master", repoBuilder.Git.Hd.Head.Branch); }
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()); }
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()); }
public void When_one_commit_Then_log_one_line() { var repoBuilder = new RepoBuilder(new Guid("6c7f821e-5cb2-45de-9365-3e35887c0ee6")) .EmptyRepo() .AddFile("a.txt", "some content"); repoBuilder.Git.Commit("Add a.txt", "kasper graversen", new DateTime(2018, 3, 1, 12, 22, 33)); Assert.Equal(@"Log for master * 06cd57d - Add a.txt (2018/03/01 12:22:33) <kasper graversen> ", repoBuilder.Git.Log()); }
public void When_branching_Then_Branchinfo_show_new_branchname() { repoBuilder = new RepoBuilder(@"c:\temp\"); repoBuilder .EmptyRepo() .AddFile("a.txt") .Commit(); Assert.Equal("* master", repoBuilder.Git.Branch()); repoBuilder.NewBranch("featurebranch"); Assert.Equal(@"* featurebranch master", repoBuilder.Git.Branch()); }
public void Given_two_toplevel_files_Then_() { repoBuilder = new RepoBuilder(@"c:\temp\"); var git = repoBuilder.BuildEmptyRepo(); repoBuilder.AddFile("car.txt", "car"); repoBuilder.AddFile("door.txt", "door"); var files = FileSystemScanFolder(git); Assert.Equal(@"tree 2 blob car.txt blob door.txt", files); }
public void When_two_commits_Then_log_twoline() { var repoBuilder = new RepoBuilder(new Guid("b3b12f1c-f455-4987-b2d7-5db08d9e1ee4")) .EmptyRepo() .AddFile("a.txt", "some content"); repoBuilder.Git.Commit("Add a.txt", "kasper graversen", new DateTime(2018, 3, 1, 12, 22, 33)); repoBuilder.AddFile("a.txt", "changed a..."); repoBuilder.Git.Commit("Changed a.txt", "kasper graversen", new DateTime(2018, 3, 2, 13, 24, 34)); Assert.Equal(@"Log for master * dd30447 - Changed a.txt (2018/03/02 01:24:34) <kasper graversen> * 06cd57d - Add a.txt (2018/03/01 12:22:33) <kasper graversen> ", repoBuilder.Git.Log()); }
public void Given_two_files_in_subfolder_Then_() { repoBuilder = new RepoBuilder(@"c:\temp\"); var git = repoBuilder.BuildEmptyRepo(); repoBuilder.AddFile(@"FeatureVolvo\car.txt", "car"); repoBuilder.AddFile(@"FeatureVolvo\door.txt", "door"); var files = FileSystemScanFolder(git); Assert.Equal( @"tree 1 tree 2 FeatureVolvo blob FeatureVolvo\car.txt blob FeatureVolvo\door.txt", files); }
public void When_pulling_Then_receive_all_nodes() { var remoteGit = new RepoBuilder().Build2Files3Commits(); var gitServer = SpinUpServer(remoteGit, 18081); var localGit = new RepoBuilder().EmptyRepo().AddLocalHostRemote(18081).Git; new GitNetworkClient().PullBranch(localGit.Hd.Remotes.First(), "master", localGit); Assert.Equal(@"Log for master Log for origin/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> ", localGit.Log()); gitServer.Abort(); }
public void When_detached_head_Then_git_branches_shows_detached_as_branch() { repoBuilder = new RepoBuilder(@"c:\temp\"); var detachedId = repoBuilder .EmptyRepo() .AddFile("a.txt") .Commit(); repoBuilder .AddFile("b.txt") .Commit(); repoBuilder.Git.Checkout(detachedId); Assert.Equal($@"* (HEAD detached at {detachedId.ToString().Substring(0, 7)}) master", repoBuilder.Git.Branch()); }
public void When_two_commits_Then_log_twoline() { var repoBuilder = new RepoBuilder(new Guid("b3b12f1c-f455-4987-b2d7-5db08d9e1ee4")) .EmptyRepo() .AddFile("a.txt", "some content"); repoBuilder.Git.Commit("Add a.txt", "kasper graversen", new DateTime(2018, 3, 1, 12, 22, 33)); repoBuilder.AddFile("a.txt", "changed a..."); repoBuilder.Git.Commit("Changed a.txt", "kasper graversen", new DateTime(2018, 3, 2, 13, 24, 34)); var actual = repoBuilder.Git.Log(); Assert.Equal(@" Log for master * dd3044753fdb212c9248da29005a6d4765e3bbe302efff96a9321bf8ea710b83 - Changed a.txt (2018/03/02 01:24:34) <kasper graversen> * 06cd57d8d2feececc9eb48adda4cea5b57482324267f1e9632c16079ac6d793e - Add a.txt (2018/03/01 12:22:33) <kasper graversen> ", actual); }
public void When_pulling_Then_receive_all_nodes() { var remoteGit = new RepoBuilder().Build2Files3Commits(); var gitServer = SpinUpServer(remoteGit, 18081); var localGit = new RepoBuilder().EmptyRepo().AddLocalHostRemote(18081).Git; new GitNetworkClient().PullBranch(localGit.Hd.Remotes.First(), "master", localGit); var actual = localGit.Log(); Assert.Equal(@" Log for master Log for origin/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(); }
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(); }
public void When_two_commits_on_master_and_one_on_feature_Then_log_both_branches() { var repoBuilder = new RepoBuilder(new Guid("186d2ac8-1e9c-4e86-b1ac-b18208adead4")) .EmptyRepo() .AddFile("a.txt", "some content"); repoBuilder.Git.Commit("Add a.txt", "kasper graversen", new DateTime(2018, 3, 1, 12, 22, 33)); repoBuilder.AddFile("a.txt", "changed a..."); repoBuilder.Git.Commit("Changed a.txt", "kasper graversen", new DateTime(2018, 3, 2, 13, 24, 34)); repoBuilder .NewBranch("feature/speed") .AddFile("a.txt", "speedup!") .Git.Commit("Speedup a.txt", "kasper graversen", new DateTime(2018, 4, 3, 15, 26, 37)); Assert.Equal(@"Log for master * dd30447 - Changed a.txt (2018/03/02 01:24:34) <kasper graversen> * 06cd57d - Add a.txt (2018/03/01 12:22:33) <kasper graversen> Log for feature/speed * fafcd20 - Speedup a.txt (2018/04/03 03:26:37) <kasper graversen> * dd30447 - Changed a.txt (2018/03/02 01:24:34) <kasper graversen> * 06cd57d - Add a.txt (2018/03/01 12:22:33) <kasper graversen> ", repoBuilder.Git.Log()); }
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(); }