예제 #1
0
        public void TestGetInNotEmptyFolderWithBranch()
        {
            using (var env = new TestEnvironment())
            {
                var dir = env.WorkingDirectory.Path;

                env.CreateRepo("A", new Dictionary <string, DepsContent>
                {
                    { "full-build", new DepsContent(null, new List <Dep>()) }
                });

                env.CommitIntoRemote("A", "test.txt", "hello");
                env.AddBranch("A", "new_branch");
                env.Checkout("A", "new_branch");
                env.CommitIntoRemote("A", "test.txt", "hello2");

                var localA = Path.Combine(dir, "A");
                Directory.CreateDirectory(localA);
                File.WriteAllText(Path.Combine(localA, "test.txt"), "bye");

                env.Get("A", "new_branch");
                var newText = File.ReadAllText(Path.Combine(localA, "test.txt"));
                Assert.That(newText == "hello2");
            }
        }
예제 #2
0
        private static void TestAddGit(string oldContent, string moduleName, string push, string fetch, string answer)
        {
            using (var env = new TestEnvironment())
            {
                env.CreateRepo("modulesRepo");
                env.CommitIntoRemote("modulesRepo", "modules", oldContent);

                env.AddBranch("modulesRepo", "tmp");
                env.Checkout("modulesRepo", "tmp");
                var package = new Package("test_package", Path.Combine(env.RemoteWorkspace, "modulesRepo"));
                if (ModuleCommand.AddModule(package, moduleName, push, fetch) != 0)
                {
                    throw new CementException("");
                }
                env.Checkout("modulesRepo", "master");

                var path = Path.Combine(env.RemoteWorkspace, "modulesRepo", "modules");
                var text = File.ReadAllText(path);
                text   = Helper.FixLineEndings(text);
                answer = Helper.FixLineEndings(answer);
                Assert.AreEqual(answer, text);
            }
        }
예제 #3
0
        public void TestGetDepsOneDepWithCreatingNewRemoteBranch()
        {
            using (var env = new TestEnvironment())
            {
                var dir = env.WorkingDirectory.Path;

                env.CreateRepo("A", new Dictionary <string, DepsContent>
                {
                    { "full-build", new DepsContent(new[]  { "%CURRENT_BRANCH%" }, new List <Dep> {
                            new Dep("B")
                        }) }
                }, new[] { "new" }, DepsFormatStyle.Ini);
                env.Checkout("A", "new");

                env.CreateRepo("B");

                env.Get("A", "new");
                env.AddBranch("B", "new");
                env.Get("A", "new");

                Assert.IsTrue(Directory.Exists(Path.Combine(dir, "A")));
                Assert.AreEqual("new", new GitRepository("B", dir, Log).CurrentLocalTreeish().Value);
            }
        }