public void TestFetchArguments() { // TODO produce a valid working directory var module = new VsrModule(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); } }
public void FetchCmd() { // TODO test case where this is false Assert.IsTrue(VsrVersion.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); } }