push.setAll(all);
final TransferSummary dataPushed = command.setAll(pushAll).setRemote(remoteName).call(); context.setResponseContent(new CommandResponse() { @Override
@Test public void testPushCommitsFromSparseClone() throws Exception { setupSparseClone(); // Add some commits to the local (sparse) repository List<Feature> features = Arrays.asList(city1, city1_modified, road3); LinkedList<RevCommit> expected = new LinkedList<RevCommit>(); Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>(); for (Feature f : features) { ObjectId oId = insertAndAdd(localGeogig.geogig, f); oids.put(f, oId); final RevCommit commit = localGeogig.geogig.command(CommitOp.class) .setMessage(f.getIdentifier().toString()).call(); expected.addFirst(commit); Optional<RevObject> childObject = localGeogig.geogig.command(RevObjectParse.class) .setObjectId(oId).call(); assertTrue(childObject.isPresent()); } PushOp push = pushOp(); push.setAll(true).call(); List<RevCommit> logged = newArrayList(remoteGeogig.geogig.command(LogOp.class).call()); assertEquals("Roads.3", logged.get(0).getMessage()); assertFalse(expected.get(0).getId().equals(logged.get(0).getId())); assertEquals("Cities.1", logged.get(1).getMessage()); assertFalse(expected.get(1).getId().equals(logged.get(1).getId())); assertEquals("Cities.1", logged.get(2).getMessage()); assertFalse(expected.get(2).getId().equals(logged.get(2).getId())); assertExists(remoteGeogig, oids.get(city1), oids.get(city1_modified), oids.get(road3)); }
@Test public void testPushCommitsFromSparseClone() throws Exception { setupSparseClone(); // Add some commits to the local (sparse) repository List<Feature> features = Arrays.asList(city1, city1_modified, road3); LinkedList<RevCommit> expected = new LinkedList<RevCommit>(); Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>(); for (Feature f : features) { ObjectId oId = insertAndAdd(localGeogig.geogig, f); oids.put(f, oId); final RevCommit commit = localGeogig.geogig.command(CommitOp.class) .setMessage(f.getIdentifier().toString()).call(); expected.addFirst(commit); Optional<RevObject> childObject = localGeogig.geogig.command(RevObjectParse.class) .setObjectId(oId).call(); assertTrue(childObject.isPresent()); } PushOp push = pushOp(); push.setAll(true).call(); List<RevCommit> logged = newArrayList(remoteGeogig.geogig.command(LogOp.class).call()); assertEquals("Roads.3", logged.get(0).getMessage()); assertFalse(expected.get(0).getId().equals(logged.get(0).getId())); assertEquals("Cities.1", logged.get(1).getMessage()); assertFalse(expected.get(1).getId().equals(logged.get(1).getId())); assertEquals("Cities.1", logged.get(2).getMessage()); assertFalse(expected.get(2).getId().equals(logged.get(2).getId())); assertExists(remoteGeogig, oids.get(city1), oids.get(city1_modified), oids.get(road3)); }
@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); }