Search in sources :

Example 86 with RevCommit

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

the class CherryPickOpTest method testCherryPickExistingCommit.

@Test
public void testCherryPickExistingCommit() throws Exception {
    insertAndAdd(points1);
    final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    CherryPickOp cherryPick = geogig.command(CherryPickOp.class);
    cherryPick.setCommit(Suppliers.ofInstance(c1.getId()));
    exception.expect(NothingToCommitException.class);
    cherryPick.call();
}
Also used : CherryPickOp(org.locationtech.geogig.api.porcelain.CherryPickOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 87 with RevCommit

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

the class CloneOpTest method testClone.

@Test
public void testClone() throws Exception {
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(0);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Make sure the local repository got all of the commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 88 with RevCommit

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

the class CloneOpTest method testShallowClone.

@Test
public void testShallowClone() throws Exception {
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(2);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Make sure the local repository got only 2 commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(2, logged.size());
    assertEquals(expected.get(0), logged.get(0));
    assertEquals(expected.get(1), logged.get(1));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 89 with RevCommit

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

the class RevCommitSerializationTest method testCommitRoundTrippin.

@Test
public void testCommitRoundTrippin() throws Exception {
    long currentTime = System.currentTimeMillis();
    int timeZoneOffset = TimeZone.getDefault().getOffset(currentTime);
    CommitBuilder builder = new CommitBuilder();
    String author = "groldan";
    builder.setAuthor(author);
    String authorEmail = "groldan@boundlessgeo.com";
    builder.setAuthorEmail(authorEmail);
    builder.setAuthorTimestamp(currentTime);
    builder.setAuthorTimeZoneOffset(timeZoneOffset);
    String committer = "mleslie";
    builder.setCommitter(committer);
    String committerEmail = "mleslie@boundlessgeo.com";
    builder.setCommitterEmail(committerEmail);
    builder.setCommitterTimestamp(currentTime);
    builder.setCommitterTimeZoneOffset(timeZoneOffset);
    ObjectId treeId = ObjectId.forString("Fake tree");
    builder.setTreeId(treeId);
    ObjectId parent1 = ObjectId.forString("Parent 1 of fake commit");
    ObjectId parent2 = ObjectId.forString("Parent 2 of fake commit");
    List<ObjectId> parents = Arrays.asList(parent1, parent2);
    builder.setParentIds(parents);
    RevCommit cmtIn = builder.build();
    assertNotNull(cmtIn);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectWriter<RevCommit> write = factory.createObjectWriter(TYPE.COMMIT);
    write.write(cmtIn, bout);
    // System.err.println(bout);
    byte[] bytes = bout.toByteArray();
    assertTrue(bytes.length > 0);
    ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
    ObjectReader<RevCommit> read = factory.createCommitReader();
    RevCommit cmtOut = read.read(cmtIn.getId(), bin);
    assertEquals(treeId, cmtOut.getTreeId());
    assertEquals(parents, cmtOut.getParentIds());
    assertEquals(author, cmtOut.getAuthor().getName().get());
    assertEquals(authorEmail, cmtOut.getAuthor().getEmail().get());
    assertEquals(committer, cmtOut.getCommitter().getName().get());
    assertEquals(committerEmail, cmtOut.getCommitter().getEmail().get());
    assertEquals(currentTime, cmtOut.getCommitter().getTimestamp());
    assertEquals(timeZoneOffset, cmtOut.getCommitter().getTimeZoneOffset());
    assertEquals(currentTime, cmtOut.getAuthor().getTimestamp());
    assertEquals(timeZoneOffset, cmtOut.getAuthor().getTimeZoneOffset());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) ByteArrayInputStream(java.io.ByteArrayInputStream) CommitBuilder(org.locationtech.geogig.api.CommitBuilder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 90 with RevCommit

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

the class CheckoutOpTest method testCheckoutCommitDettachedHead.

@Test
public void testCheckoutCommitDettachedHead() throws Exception {
    insertAndAdd(points1);
    final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    insertAndAdd(points2);
    final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    insertAndAdd(lines1);
    final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
    CheckoutResult result;
    result = geogig.command(CheckoutOp.class).setSource(c1.getId().toString()).call();
    assertEquals(c1.getTreeId(), result.getNewTree());
    assertFalse(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
    assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof Ref);
    result = geogig.command(CheckoutOp.class).setSource(c2.getId().toString()).call();
    assertEquals(c2.getTreeId(), result.getNewTree());
    result = geogig.command(CheckoutOp.class).setSource(c3.getId().toString()).call();
    assertEquals(c3.getTreeId(), result.getNewTree());
}
Also used : SymRef(org.locationtech.geogig.api.SymRef) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) NodeRef(org.locationtech.geogig.api.NodeRef) CheckoutResult(org.locationtech.geogig.api.porcelain.CheckoutResult) CheckoutOp(org.locationtech.geogig.api.porcelain.CheckoutOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

RevCommit (org.locationtech.geogig.api.RevCommit)291 Test (org.junit.Test)212 ObjectId (org.locationtech.geogig.api.ObjectId)109 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)107 LogOp (org.locationtech.geogig.api.porcelain.LogOp)86 Ref (org.locationtech.geogig.api.Ref)71 Feature (org.opengis.feature.Feature)52 NodeRef (org.locationtech.geogig.api.NodeRef)47 ArrayList (java.util.ArrayList)44 BranchCreateOp (org.locationtech.geogig.api.porcelain.BranchCreateOp)44 RevTree (org.locationtech.geogig.api.RevTree)36 SymRef (org.locationtech.geogig.api.SymRef)33 RefParse (org.locationtech.geogig.api.plumbing.RefParse)33 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)31 RevObject (org.locationtech.geogig.api.RevObject)30 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)30 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)30 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)26 LinkedList (java.util.LinkedList)24 AddOp (org.locationtech.geogig.api.porcelain.AddOp)21