Beispiel #1
0
        public void TestFetchWithUncommitedModifiedChanges()
        {
            string repoA = paths[5];
            string repoB = paths[6];

            // 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(repoB, "first.txt", "B Content in first"); // then write an uncommitted change to repo B
            gitB.FetchLatest(remoteName: "repoA");

            AssertFileExists(repoB, "first.txt");
            AssertFileContent(repoB, "first.txt", "first Content");
        }
Beispiel #2
0
        public void TestHasChanges()
        {
            string rep = paths[4];
            Gitmo git = new Gitmo(rep);
            Write(rep, "dirty.txt", "drrrty");

            Assert.IsTrue(git.HasChanges);
        }
Beispiel #3
0
        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"));
        }
Beispiel #4
0
        public void TestZipDirectory()
        {
            string repositoryPath = paths[1];

            Write(repositoryPath, "somefile.txt", "somecontent");

            Gitmo g = new Gitmo(repositoryPath);

            string archiveID = "theid";
            string relativePathInRepository = ""; // whole thing
            string outPath = "Test";

            g.Zip(archiveID, relativePathInRepository, outPath);

            Assert.IsTrue(IO.File.Exists("Test/theid.zip"));
        }
Beispiel #5
0
        public void TestResetZipConfig_withRebuild()
        {
            string repositoryPath = paths[1];

            IO.File.WriteAllText(IO.Path.Combine(repositoryPath, "someOtherfile.txt"), DateTime.Now.ToString());

            Gitmo g = new Gitmo(repositoryPath);

            string archiveID = "theid_clean_withrebuild";
            string relativePathInRepository = ""; // whole thing
            string outPath = "Test";

            g.Zip(archiveID, relativePathInRepository, outPath);

            string configFile = g.ResetZipConfig(archiveID, outPath);

            bool wasRebuilt = g.Zip(archiveID, relativePathInRepository, outPath);

            Assert.IsTrue(wasRebuilt, "Archive wasn't rebuilt after resetting the config");
            Assert.IsTrue(IO.File.Exists(configFile), "Config File wasn't recreated");
        }
Beispiel #6
0
        public void TestResetZipConfig()
        {
            string repositoryPath = paths[1];

            IO.File.WriteAllText(IO.Path.Combine(repositoryPath, "someOtherfile.txt"), DateTime.Now.ToString());

            Gitmo g = new Gitmo(repositoryPath);

            string archiveID = "theid_clean";
            string relativePathInRepository = ""; // whole thing
            string outPath = "Test";

            g.Zip(archiveID, relativePathInRepository, outPath);

            string configFile = g.ResetZipConfig(archiveID, outPath);

            Assert.IsFalse(IO.File.Exists(configFile));
        }