push.setRemote(args.get(0));
push.setRemote(args.get(0));
push.setRemote(args.get(0));
final TransferSummary dataPushed = command.setAll(pushAll).setRemote(remoteName).call(); context.setResponseContent(new CommandResponse() { @Override
@Test public void testPushToRemote() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Optional<Ref> oldBranch = getRef(remoteRepo, "master"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setRemote("origin").call(); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "master")); // 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 testPushToRemote() throws Exception { // Add a commit to the local repository insertAndAdd(localRepo, lines3); RevCommit commit = localRepo.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Optional<Ref> oldBranch = getRef(remoteRepo, "master"); // Push the commit PushOp push = pushOp(); TransferSummary summary = push.setRemote("origin").call(); assertSummary(summary, remote.getPushURL(), oldBranch, getRef(localRepo, "master")); // 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 testPushToRemoteHEAD() throws Exception { insertAndAdd(localRepo, lines3); localRepo.command(CommitOp.class).call(); PushOp push = pushOp(); try { push.setRemote("origin").addRefSpec("HEAD").call(); fail(); } catch (SynchronizationException e) { assertEquals(SynchronizationException.StatusCode.CANNOT_PUSH_TO_SYMBOLIC_REF, e.statusCode); } }
@Test public void testPushToRemoteHEAD() throws Exception { insertAndAdd(localRepo, lines3); localRepo.command(CommitOp.class).call(); PushOp push = pushOp(); try { push.setRemote("origin").addRefSpec("HEAD").call(); fail(); } catch (SynchronizationException e) { assertEquals(SynchronizationException.StatusCode.CANNOT_PUSH_TO_SYMBOLIC_REF, e.statusCode); } }