Search in sources :

Example 1 with PullOp

use of org.locationtech.geogig.api.porcelain.PullOp in project GeoGig by boundlessgeo.

the class SparseCloneTest method testPullCommitThatPassesFilter.

@Test
public void testPullCommitThatPassesFilter() throws Exception {
    setupSparseClone();
    // Add a commit that passes our filter to the remote.
    ObjectId oId = insertAndAdd(remoteGeogig.geogig, city1_modified);
    final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(city1_modified.getIdentifier().toString()).call();
    Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
    assertTrue(childObject.isPresent());
    assertEquals(commit, remoteGeogig.geogig.getRepository().objectDatabase().getCommit(commit.getId()));
    PullOp pull = pull();
    pull.call();
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals("Cities.1", logged.get(0).getMessage());
    assertFalse(commit.getId().equals(logged.get(0).getId()));
    assertExists(localGeogig, oId);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 2 with PullOp

use of org.locationtech.geogig.api.porcelain.PullOp in project GeoGig by boundlessgeo.

the class PullOpTest method testPullRebase.

@Test
public void testPullRebase() 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 = pull();
    pull.setRebase(true).setAll(true).call();
    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);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 3 with PullOp

use of org.locationtech.geogig.api.porcelain.PullOp in project GeoGig by boundlessgeo.

the class PullOpTest method testPullRefspecs.

@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 = pull();
    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);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) SymRef(org.locationtech.geogig.api.SymRef) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 4 with PullOp

use of org.locationtech.geogig.api.porcelain.PullOp in project GeoGig by boundlessgeo.

the class PullOpTest method testPullToCurrentBranch.

@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 = pull();
    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);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) SymRef(org.locationtech.geogig.api.SymRef) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 5 with PullOp

use of org.locationtech.geogig.api.porcelain.PullOp in project GeoGig by boundlessgeo.

the class PullOpTest method testPullTooManyRefs.

@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 = pull();
    pull.addRefSpec("master:newbranch:newbranch2");
    exception.expect(IllegalArgumentException.class);
    pull.setRebase(true).call();
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

PullOp (org.locationtech.geogig.api.porcelain.PullOp)13 RevCommit (org.locationtech.geogig.api.RevCommit)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 LogOp (org.locationtech.geogig.api.porcelain.LogOp)9 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)8 Ref (org.locationtech.geogig.api.Ref)5 SymRef (org.locationtech.geogig.api.SymRef)5 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)5 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)5 ObjectId (org.locationtech.geogig.api.ObjectId)2 RevObject (org.locationtech.geogig.api.RevObject)2 PullResult (org.locationtech.geogig.api.porcelain.PullResult)2 SynchronizationException (org.locationtech.geogig.api.porcelain.SynchronizationException)2 Optional (com.google.common.base.Optional)1 ConsoleReader (jline.console.ConsoleReader)1 Context (org.locationtech.geogig.api.Context)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 LsRemote (org.locationtech.geogig.api.plumbing.LsRemote)1 RefParse (org.locationtech.geogig.api.plumbing.RefParse)1