private PullResult pull(final GeogigTransaction context, final Remote remote) throws MergeConflictsException { String fetchSpec = remote.getFetchSpec(); PullResult pullResult = context.command(PullOp.class)// .setAll(false)// .setIncludeIndexes(true)// .setRemote(remote)// .addRefSpec(fetchSpec)// .setNoFastForward(true)// .setMessage(message)// .setProgressListener(getProgressListener())// .call(); return pullResult; }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testPullRefspecs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); checkout(localGeogig.repo, "Branch1"); List<RevCommit> logged = log(localGeogig.repo); assertEquals(3, logged.size()); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/Branch1").isPresent()); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1"); PullResult result = pull.setRebase(true).call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/Branch1").isPresent()); logged = log(localGeogig.repo); assertEquals(8, logged.size()); }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testPullRefspecForce() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("+master:newbranch"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("newbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.setRebase(true).call();
@Test public void testPullRefspecs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("newbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullMultipleRefspecs() throws Exception { // Add a commit to the remote checkout(remoteGeogig.repo, "master"); insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Feature points4 = feature(pointsType, "Points.4", "4", new Integer(4), "POINT(4 4)"); checkout(remoteGeogig.repo, "Branch1"); insertAndAdd(remoteGeogig.repo, points4); commit(remoteGeogig.repo, "Points.4"); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); checkout(localGeogig.repo, "Branch1"); List<RevCommit> logged = log(localGeogig.repo); assertEquals(3, logged.size()); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.setRebase(true).call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); logged = log(localGeogig.repo); assertEquals(9, logged.size()); }
@Test public void testPullMultipleRefspecsNonPersistedRemote() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // remove the remote Remote removedOrigin = localGeogig.geogig.command(RemoteRemoveOp.class).setName("origin") .call(); assertFalse(localGeogig.geogig.command(RemoteResolve.class).setName("origin").call() .isPresent()); // Pull the commit PullOp pull = pullOp(); pull.setRemote(removedOrigin);// client supplied remote pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); assertEquals(7, log(localGeogig.repo).size()); }
@Test public void testPullToCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Make sure the local master matches the remote localGeogig.geogig.command(BranchCreateOp.class).setName("mynewbranch") .setAutoCheckout(true).call(); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("mynewbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
.setAll(fetchAll).addRefSpec(refSpec); try { final PullResult result = command.call();
pull.addRefSpec(args.get(i));
pull.addRefSpec(args.get(i));
pull.addRefSpec(args.get(i));
@Test public void testPullToCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Make sure the local master matches the remote localGeogig.geogig.command(BranchCreateOp.class).setName("mynewbranch") .setAutoCheckout(true).call(); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("mynewbranch", currentBranch); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); }
@Test public void testPullRefspecForce() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); // fetch remote's master onto new ref refs/remotes/origin/newbranch, then pull from there pull.addRefSpec("+master:newbranch"); PullResult result = pull.setRebase(true).call(); Optional<Ref> fetchedToRef = getRef(localGeogig.repo, "refs/remotes/origin/newbranch"); assertTrue(fetchedToRef.isPresent()); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); Ref oldRef = result.getOldRef(); Ref newRef = result.getNewRef(); assertEquals("refs/heads/master", oldRef.getName()); assertEquals("refs/heads/master", newRef.getName()); assertEquals(fetchedToRef.get().getObjectId(), newRef.getObjectId()); }
public @Test void prepareAndManuallyResolveAllConflicts() { createConflicts(TestData.point1, TestData.line1, TestData.poly1); PRStatus result = prepare(); assertEquals(3, result.getNumConflicts()); final UUID transactionId = request.getTransactionId(); origin.resumeTransaction(transactionId); assertEquals(request.getTargetBranch(), origin.getRef("HEAD").peel().localName()); //@formatter:off SimpleFeature c1 = TestData.clone(TestData.point1); c1.setAttribute("sp", "manually set"); SimpleFeature c2 = TestData.clone(TestData.line1); c2.setAttribute("sp", "manually set"); SimpleFeature c3 = TestData.clone(TestData.poly1); c3.setAttribute("sp", "manually set"); //@formatter:on Context context = clone.checkout("issuerBranch").getContext(); try { PullResult pres = context.command(PullOp.class).addRefSpec("master").call(); fail("Expected MergeConflictsException , got " + pres); } catch (MergeConflictsException e) { assertEquals(3, e.getReport().getConflicts()); clone.insert(c1, c2, c3).add().commit("manual conflict fix"); } result = prepare(); assertTrue(result.getMergeCommit().isPresent()); assertTrue(result.getReport().isPresent()); GeogigTransaction prtx = getTransaction(); Optional<Ref> mergeRef = request.resolveMergeRef(prtx); assertTrue(mergeRef.isPresent()); assertEquals(result.getMergeCommit().get(), mergeRef.get().getObjectId()); }
PullResult pres = context.command(PullOp.class).addRefSpec("master").call(); fail("Expected MergeConflictsException , got " + pres); } catch (MergeConflictsException e) {
try { PullResult pres = context.command(PullOp.class).setIncludeIndexes(true) .addRefSpec("master").call(); fail("Expected MergeConflictsException , got " + pres); } catch (MergeConflictsException e) {