public void TestFetchArguments()
 {
     GitModule module = new GitModule(null);
     { // Using a registered remote creates a local branch (FIXME: Change that)
         var fetchCmd = module.FetchCmd("origin", "some-branch", "local");
         Assert.AreEqual("fetch --progress \"origin\" +some-branch:refs/remotes/origin/local --no-tags", fetchCmd);
     }
     {
         var fetchCmd = module.FetchCmd("origin", "some-branch", "local", true);
         Assert.AreEqual("fetch --progress \"origin\" +some-branch:refs/remotes/origin/local --tags", fetchCmd);
     }
     { // Using a URL as remote and passing a local branch creates the branch
         var fetchCmd = module.FetchCmd("https://host.com/repo", "some-branch", "local");
         Assert.AreEqual("fetch --progress \"https://host.com/repo\" +some-branch:refs/heads/local --no-tags", fetchCmd);
     }
     { // Using a URL as remote and not passing a local branch
         var fetchCmd = module.FetchCmd("https://host.com/repo", "some-branch", null);
         Assert.AreEqual("fetch --progress \"https://host.com/repo\" +some-branch --no-tags", fetchCmd);
     }
     { // Pull doesn't accept a local branch ever
         var fetchCmd = module.PullCmd("origin", "some-branch", false);
         Assert.AreEqual("pull --progress \"origin\" +some-branch --no-tags", fetchCmd);
     }
     { // Not even for URL remote
         var fetchCmd = module.PullCmd("https://host.com/repo", "some-branch", false);
         Assert.AreEqual("pull --progress \"https://host.com/repo\" +some-branch --no-tags", fetchCmd);
     }
     { // Pull with rebase
         var fetchCmd = module.PullCmd("origin", "some-branch", true);
         Assert.AreEqual("pull --rebase --progress \"origin\" +some-branch --no-tags", fetchCmd);
     }
 }
        public void TestFetchArguments()
        {
            // TODO produce a valid working directory
            var module = new GitModule(Path.GetTempPath());
            {
                // Specifying a remote and a local branch creates a local branch
                var fetchCmd = module.FetchCmd("origin", "some-branch", "local").Arguments;
                Assert.AreEqual("fetch --progress \"origin\" +some-branch:refs/heads/local --no-tags", fetchCmd);
            }

            {
                var fetchCmd = module.FetchCmd("origin", "some-branch", "local", true).Arguments;
                Assert.AreEqual("fetch --progress \"origin\" +some-branch:refs/heads/local --tags", fetchCmd);
            }

            {
                // Using a URL as remote and passing a local branch creates the branch
                var fetchCmd = module.FetchCmd("https://host.com/repo", "some-branch", "local").Arguments;
                Assert.AreEqual("fetch --progress \"https://host.com/repo\" +some-branch:refs/heads/local --no-tags", fetchCmd);
            }

            {
                // Using a URL as remote and not passing a local branch
                var fetchCmd = module.FetchCmd("https://host.com/repo", "some-branch", null).Arguments;
                Assert.AreEqual("fetch --progress \"https://host.com/repo\" +some-branch --no-tags", fetchCmd);
            }

            {
                // No remote branch -> No local branch
                var fetchCmd = module.FetchCmd("origin", "", "local").Arguments;
                Assert.AreEqual("fetch --progress \"origin\" --no-tags", fetchCmd);
            }

            {
                // Pull doesn't accept a local branch ever
                var fetchCmd = module.PullCmd("origin", "some-branch", false).Arguments;
                Assert.AreEqual("pull --progress \"origin\" +some-branch --no-tags", fetchCmd);
            }

            {
                // Not even for URL remote
                var fetchCmd = module.PullCmd("https://host.com/repo", "some-branch", false).Arguments;
                Assert.AreEqual("pull --progress \"https://host.com/repo\" +some-branch --no-tags", fetchCmd);
            }

            {
                // Pull with rebase
                var fetchCmd = module.PullCmd("origin", "some-branch", true).Arguments;
                Assert.AreEqual("pull --rebase --progress \"origin\" +some-branch --no-tags", fetchCmd);
            }
        }
Ejemplo n.º 3
0
        public void FetchCmd()
        {
            // TODO test case where this is false
            Assert.IsTrue(GitCommandHelpers.VersionInUse.FetchCanAskForProgress);

            Assert.AreEqual(
                "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags",
                _gitModule.FetchCmd("remote", "remotebranch", "localbranch"));
            Assert.AreEqual(
                "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --tags",
                _gitModule.FetchCmd("remote", "remotebranch", "localbranch", true));
            Assert.AreEqual(
                "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch",
                _gitModule.FetchCmd("remote", "remotebranch", "localbranch", null));
            Assert.AreEqual(
                "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --unshallow",
                _gitModule.FetchCmd("remote", "remotebranch", "localbranch", isUnshallow: true));
            Assert.AreEqual(
                "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --prune",
                _gitModule.FetchCmd("remote", "remotebranch", "localbranch", prune: true));
        }
Ejemplo n.º 4
0
        public void FetchCmd()
        {
            // TODO test case where this is false
            Assert.IsTrue(GitVersion.Current.FetchCanAskForProgress);

            using (_executable.StageOutput("rev-parse \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch").Arguments);
            }

            using (_executable.StageOutput("rev-parse \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --tags",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", true).Arguments);
            }

            using (_executable.StageOutput("rev-parse \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", null).Arguments);
            }

            using (_executable.StageOutput("rev-parse \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --unshallow",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", isUnshallow: true).Arguments);
            }

            using (_executable.StageOutput("rev-parse \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --prune",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", prune: true).Arguments);
            }
        }
Ejemplo n.º 5
0
        public void CheckoutBranch(string branch)
        {
            var defaultRemote = _gitModule.GetCurrentRemote();

            var remoteBranch = $"{defaultRemote}/{branch}";

            _gitUiCommands.RepoChangedNotifier.Lock();

            var gitFetchCmfArgs = _gitModule.FetchCmd(string.Empty, string.Empty, string.Empty);

            FormProcess.ShowDialog((GitModuleForm)_ownerForm, gitFetchCmfArgs);

            _gitUiCommands.RepoChangedNotifier.Notify();

            _gitUiCommands.StartCheckoutRemoteBranch(_ownerForm, remoteBranch);

            _gitUiCommands.RepoChangedNotifier.UnLock(requestNotify: true);
        }
Ejemplo n.º 6
0
        public void FetchCmd()
        {
            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch").Arguments);
            }

            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --tags",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", true).Arguments);
            }

            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", null).Arguments);
            }

            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --unshallow",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", isUnshallow: true).Arguments);
            }

            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --prune",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", pruneRemoteBranches: true).Arguments);
            }

            using (_executable.StageOutput("rev-parse --quiet --verify \"refs/heads/remotebranch~0\"", null))
            {
                Assert.AreEqual(
                    "fetch --progress \"remote\" +remotebranch:refs/heads/localbranch --no-tags --prune --prune-tags",
                    _gitModule.FetchCmd("remote", "remotebranch", "localbranch", pruneRemoteBranches: true, pruneRemoteBranchesAndTags: true).Arguments);
            }
        }