push.setProgressListener(cli.getProgressListener()); push.setAll(all);
push.setProgressListener(cli.getProgressListener()); push.setAll(all);
push.setProgressListener(cli.getProgressListener()); push.setAll(all);
@Test public void testPush() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Optional<Ref> oldRef = getRef(remoteRepo, "master"); Optional<Ref> newRef = getRef(localRepo, "master"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldRef, newRef); // verify that the remote got the commit List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); // verify that the local reference of the remote master is updated Optional<Ref> ref = localRepo.command(RefParse.class) .setName(Ref.append(Ref.REMOTES_PREFIX, "origin/master")).call(); assertTrue(ref.isPresent()); assertEquals(logged.get(0).getId(), ref.get().getObjectId()); }
@Test public void testPush() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Optional<Ref> oldRef = getRef(remoteRepo, "master"); Optional<Ref> newRef = getRef(localRepo, "master"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldRef, newRef); // verify that the remote got the commit List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); // verify that the local reference of the remote master is updated Optional<Ref> ref = localRepo.command(RefParse.class) .setName(Ref.append(Ref.REMOTES_PREFIX, "origin/master")).call(); assertTrue(ref.isPresent()); assertEquals(logged.get(0).getId(), ref.get().getObjectId()); }
@Test public void testPushWithRefSpec() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Push the commit PushOp push = pushOp(); push.addRefSpec("master:NewRemoteBranch"); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), null, new Ref("refs/heads/NewRemoteBranch", commit.getId())); assertTrue(getRef(remoteRepo, "NewRemoteBranch").isPresent()); // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("NewRemoteBranch").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); // verify that the local reference of the remote master is updated Optional<Ref> ref = localRepo.command(RefParse.class) .setName(Ref.append(Ref.REMOTES_PREFIX, "origin/NewRemoteBranch")).call(); assertTrue(ref.isPresent()); assertEquals(logged.get(0).getId(), ref.get().getObjectId()); TestSupport.verifyRepositoryContents(remoteRepo); }
@Test public void testNothingToPush() throws Exception { Optional<Ref> master = getRef(remoteRepo, "master"); Optional<Ref> branch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertTrue(summary.isEmpty()); assertEquals(master, getRef(remoteRepo, "master")); assertEquals(branch, getRef(remoteRepo, "Branch1")); }
@Test public void testPushWithRefSpec() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Push the commit PushOp push = pushOp(); push.addRefSpec("master:NewRemoteBranch"); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), null, new Ref("refs/heads/NewRemoteBranch", commit.getId())); assertTrue(getRef(remoteRepo, "NewRemoteBranch").isPresent()); // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("NewRemoteBranch").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); // verify that the local reference of the remote master is updated Optional<Ref> ref = localRepo.command(RefParse.class) .setName(Ref.append(Ref.REMOTES_PREFIX, "origin/NewRemoteBranch")).call(); assertTrue(ref.isPresent()); assertEquals(logged.get(0).getId(), ref.get().getObjectId()); TestSupport.verifyRepositoryContents(remoteRepo); }
@Test public void testNothingToPush() throws Exception { Optional<Ref> master = getRef(remoteRepo, "master"); Optional<Ref> branch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertTrue(summary.isEmpty()); assertEquals(master, getRef(remoteRepo, "master")); assertEquals(branch, getRef(remoteRepo, "Branch1")); }
TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldRef, newRef);
TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldRef, newRef);
@Test public void testPushBranchNoForce() throws Exception { // Add a commit to the remote repository remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(remoteRepo, points1_modified); RevCommit remotesTip = remoteRepo.command(CommitOp.class).call(); // Add a commit to the local repository localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, lines3); localRepo.command(CommitOp.class).call(); // Push the commit PushOp push = pushOp(); push.addRefSpec("Branch1"); try { push.setProgressListener(SIMPLE_PROGRESS).call(); fail(); } catch (SynchronizationException e) { assertEquals(StatusCode.REMOTE_HAS_CHANGES, e.statusCode); } // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals("remote shouldn't have changed", remotesTip, logged.get(0)); }
@Test public void testPushAll() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, points1_modified); RevCommit commit2 = localRepo.command(CommitOp.class).call(); expectedBranch.addFirst(commit2); Optional<Ref> oldMaster = getRef(remoteRepo, "master"); Optional<Ref> oldBranch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setAll(true).setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldMaster, getRef(localRepo, "master")); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "Branch1")); // verify that the remote got the commit on both branches remoteRepo.command(CheckoutOp.class).setSource("master").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedBranch, logged); }
@Test public void testPushAll() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, points1_modified); RevCommit commit2 = localRepo.command(CommitOp.class).call(); expectedBranch.addFirst(commit2); Optional<Ref> oldMaster = getRef(remoteRepo, "master"); Optional<Ref> oldBranch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setAll(true).setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldMaster, getRef(localRepo, "master")); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "Branch1")); // verify that the remote got the commit on both branches remoteRepo.command(CheckoutOp.class).setSource("master").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedMaster, logged); remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedBranch, logged); }
@Test public void testPushBranchNoForce() throws Exception { // Add a commit to the remote repository remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(remoteRepo, points1_modified); RevCommit remotesTip = remoteRepo.command(CommitOp.class).call(); // Add a commit to the local repository localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, lines3); localRepo.command(CommitOp.class).call(); // Push the commit PushOp push = pushOp(); push.addRefSpec("Branch1"); try { push.setProgressListener(SIMPLE_PROGRESS).call(); fail(); } catch (SynchronizationException e) { assertEquals(StatusCode.REMOTE_HAS_CHANGES, e.statusCode); } // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals("remote shouldn't have changed", remotesTip, logged.get(0)); }
@Test public void testPushBranchForce() throws Exception { // Add a commit to the remote repository remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(remoteRepo, points1_modified); remoteRepo.command(CommitOp.class).call(); // Add a commit to the local repository localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedBranch.addFirst(commit); localRepo.command(CheckoutOp.class).setSource("master").call(); Optional<Ref> oldBranch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); push.addRefSpec("+Branch1"); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "Branch1")); // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedBranch, logged); TestSupport.verifyRepositoryContents(remoteRepo); }
@Test public void testPushBranchForce() throws Exception { // Add a commit to the remote repository remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(remoteRepo, points1_modified); remoteRepo.command(CommitOp.class).call(); // Add a commit to the local repository localRepo.command(CheckoutOp.class).setSource("Branch1").call(); insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedBranch.addFirst(commit); localRepo.command(CheckoutOp.class).setSource("master").call(); Optional<Ref> oldBranch = getRef(remoteRepo, "Branch1"); // Push the commit PushOp push = pushOp(); push.addRefSpec("+Branch1"); TransferSummary summary = push.setProgressListener(SIMPLE_PROGRESS).call(); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "Branch1")); // verify that the remote got the commit remoteRepo.command(CheckoutOp.class).setSource("Branch1").call(); List<RevCommit> logged = newArrayList(remoteRepo.command(LogOp.class).call()); assertEquals(expectedBranch, logged); TestSupport.verifyRepositoryContents(remoteRepo); }