Пример #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
        public void TestGetDepsWithBranchSwitchToHugeConfig()
        {
            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> {
                            new Dep("B@branch/client"), new Dep("Y")
                        }) }
                });
                env.CreateRepo("Y", new Dictionary <string, DepsContent>
                {
                    { "full-build *default", new DepsContent(null, new List <Dep> {
                            new Dep("B/full-build")
                        }) }
                });

                env.CreateRepo("B", new Dictionary <string, DepsContent>
                {
                    { "full-build > client *default", new DepsContent(null, new List <Dep>()) },
                    { "client", new DepsContent(null, new List <Dep> {
                            new Dep("B1")
                        }) }
                }, new[] { "master", "branch" });

                env.Checkout("B", "branch");
                using (new DirectoryJumper(Path.Combine(env.RemoteWorkspace, "B")))
                {
                    env.CreateDepsAndCommitThem(Path.Combine(env.RemoteWorkspace, "B"), new Dictionary <string, DepsContent>
                    {
                        { "full-build > client *default", new DepsContent(null, new List <Dep> {
                                new Dep("B2")
                            }) },
                        { "client", new DepsContent(null, new List <Dep> {
                                new Dep("B3")
                            }) }
                    });
                }

                env.CreateRepo("B1", new Dictionary <string, DepsContent> {
                    { "full-build *default", new DepsContent(null, new List <Dep>()) }
                });
                env.CreateRepo("B2", new Dictionary <string, DepsContent> {
                    { "full-build *default", new DepsContent(null, new List <Dep>()) }
                });
                env.CreateRepo("B3", new Dictionary <string, DepsContent> {
                    { "full-build *default", new DepsContent(null, new List <Dep>()) }
                });

                env.Get("A");

                Assert.AreEqual("branch", new GitRepository("B", dir, Log).CurrentLocalTreeish().Value);
                Assert.IsFalse(Directory.Exists(Path.Combine(dir, "B1")));
                Assert.IsTrue(Directory.Exists(Path.Combine(dir, "B2")));
                Assert.IsTrue(Directory.Exists(Path.Combine(dir, "B3")));
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        public void TestGetDepsOneDepWithCurrentBranchForceNewStyle()
        {
            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" });
                env.Checkout("A", "new");

                env.CreateRepo("B", null, new[] { "new" });

                env.Get("A", "new");
                Assert.IsTrue(Directory.Exists(Path.Combine(dir, "A")));
                Assert.AreEqual("new", new GitRepository("B", dir, Log).CurrentLocalTreeish().Value);
            }
        }
Пример #5
0
        public void TestGetDepsOneDepWithCreatingNewRemoteBranch()
        {
            using (var env = new TestEnvironment())
            {
                var dir = env.WorkingDirectory.Path;

                env.CreateRepo("A", new Dictionary <string, DepsData>
                {
                    { "full-build", new DepsData(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);
            }
        }