public void TestFetchWithUntrackedChanges() { string repoA = paths[3]; string repoB = paths[4]; // first, we set up the repositories Gitmo gitA = new Gitmo(repoA); Write(repoA, "first.txt", "first Content"); gitA.CommitChanges("initial"); // first commit, to ensure that the master branch exists Gitmo gitB = new Gitmo(repoB); gitB.AddRemote("repoA", repoA); gitB.FetchLatest(remoteName: "repoA"); // now, we set up a situation for a merge issue Write(repoA, "a.txt", "A Content"); gitA.CommitChanges("changes from A"); // we commit a change in repo A Write(repoB, "a.txt", "B Content"); // then write an uncommitted change to repo B gitB.FetchLatest(remoteName: "repoA"); AssertFileExists(repoB, "a.txt"); AssertFileContent(repoB, "a.txt", "A Content"); }
public void TestZipDirectory_WithCommit() { string repositoryPath = paths[2]; IO.Directory.CreateDirectory(IO.Path.Combine(repositoryPath, "somedir")); IO.File.WriteAllText(IO.Path.Combine(repositoryPath, "somedir", "afile.txt"), DateTime.Now.ToString()); Gitmo g = new Gitmo(repositoryPath); g.CommitChanges("a file commit"); string archiveID = "theid"; string relativePathInRepository = "somedir"; // whole thing string outPath = "Test/out"; bool didCreateZip = g.Zip(archiveID, relativePathInRepository, outPath); Assert.IsTrue(didCreateZip, "first zip not made"); didCreateZip = g.Zip(archiveID, relativePathInRepository, outPath); Assert.IsFalse(didCreateZip, "second zip attempt still made a zip"); IO.File.WriteAllText(IO.Path.Combine(repositoryPath, "somedir", "asecondfile.txt"), DateTime.Now.ToString()); Task.Delay(1000).Wait(); // required delay to make sure the second commit has a different timestamp; g.CommitChanges("second commit"); didCreateZip = g.Zip(archiveID, relativePathInRepository, outPath); Assert.IsTrue(didCreateZip, "did not create the zip after the second try"); Assert.IsTrue(IO.File.Exists("Test/out/theid.zip")); }