private void CheckKeepOnlyOneDirectoryAndFile(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); bool haveCommit2 = false; for (int i = 0; i < newCommits.Count; i++) { var commit = newCommits[i]; Assert.True(commit.Tree.Count == 1 || commit.Tree.Count == 2); Assert.NotNull(commit.Tree["a.txt"]); // /Test1 was added after a.txt if (commit.Tree.Count == 2) { haveCommit2 = true; var entry = commit.Tree["Test1"]; Assert.NotNull(entry); Assert.Equal(TreeEntryTargetType.Tree, entry.TargetType); var tree = (Tree)entry.Target; Assert.Equal(3, tree.Count); } } Assert.True(haveCommit2, "Missing commits for /Test1 folder"); }
private static void CheckKeepOnlyNonBinaryFilesLessThan10Bytes(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); foreach (var commit in newCommits) { var entries = GetEntries(commit.Tree).ToList(); foreach (var entry in entries) { var blob = (Blob)entry.Target; Assert.False(blob.IsBinary); Assert.True(blob.Size <= 10); } } }
protected DisposeTempRepo InitializeTest([System.Runtime.CompilerServices.CallerMemberName] string memberName = "") { var path = AppDomain.CurrentDomain.BaseDirectory; var repoName = GetType().Name + "_" + memberName; var repoPath = Path.Combine(path, repoName); if (Directory.Exists(repoPath)) { RemoveDirectory(repoPath); } Directory.CreateDirectory(repoPath); var repoSourcePath = Path.Combine(path, @"..\..\test_repo\"); DirectoryCopy(repoSourcePath, repoPath, true); Directory.Move(Path.Combine(repoName, "dotgit"), Path.Combine(repoName, ".git")); var tempRepo = new DisposeTempRepo(repoPath); Program.RedirectOutput = new TextWriterRedirect(outputHelper, tempRepo.OutputBuilder); return(tempRepo); }
private static void CheckKeepTwoDirectoriesAndRemoveExcept(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); for (int i = 0; i < newCommits.Count; i++) { var commit = newCommits[i]; var entries = GetEntries(commit.Tree).ToList(); // Check that we keps only a1/a2 foreach (var entry in entries) { Assert.True(entry.Name == "a1.txt" || entry.Name == "a2.txt"); Assert.True(entry.Path.StartsWith("Test1") || entry.Path.StartsWith("Test2")); } } }
private static void CheckKeepOnlyNonBinaryFilesLessThan10Bytes(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); foreach (var commit in newCommits) { var entries = GetEntries(commit.Tree).ToList(); foreach (var entry in entries) { var blob = (Blob) entry.Target; Assert.False(blob.IsBinary); Assert.True(blob.Size <= 10); } } }
protected DisposeTempRepo InitializeTest([System.Runtime.CompilerServices.CallerMemberName] string memberName = "") { var path = AppDomain.CurrentDomain.BaseDirectory; var repoName = GetType().Name + "_" + memberName; var repoPath = Path.Combine(path, repoName); if (Directory.Exists(repoPath)) { RemoveDirectory(repoPath); } Directory.CreateDirectory(repoPath); var repoSourcePath = Path.Combine(path, @"..\..\test_repo\"); DirectoryCopy(repoSourcePath, repoPath, true); Directory.Move(Path.Combine(repoName, "dotgit"), Path.Combine(repoName, ".git")); var tempRepo = new DisposeTempRepo(repoPath); Program.RedirectOutput = new TextWriterRedirect(outputHelper, tempRepo.OutputBuilder); return tempRepo; }
private void CheckKeepOnlyOneDirectoryAndFile(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); bool haveCommit2 = false; for (int i = 0; i < newCommits.Count; i++) { var commit = newCommits[i]; Assert.True(commit.Tree.Count == 1 || commit.Tree.Count == 2); Assert.NotNull(commit.Tree["a.txt"]); // /Test1 was added after a.txt if (commit.Tree.Count == 2) { haveCommit2 = true; var entry = commit.Tree["Test1"]; Assert.NotNull(entry); Assert.Equal(TreeEntryTargetType.Tree, entry.TargetType); var tree = (Tree)entry.Target; Assert.Equal(3, tree.Count); } } Assert.True(haveCommit2, "Missing commits for /Test1 folder"); }
private static void CheckKeepTwoDirectoriesAndRemoveExcept(DisposeTempRepo test) { var repo = test.Repo; var headNewMaster = AssertBranchRef(repo); var newCommits = GetCommits(repo, headNewMaster); Assert.True(newCommits.Count > 0); for (int i = 0; i < newCommits.Count; i++) { var commit = newCommits[i]; var entries = GetEntries(commit.Tree).ToList(); // Check that we keps only a1/a2 foreach (var entry in entries) { Assert.True(entry.Name == "a1.txt" || entry.Name == "a2.txt"); Assert.True(entry.Path.StartsWith("Test1") || entry.Path.StartsWith("Test2")); } } }