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();
}
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);
}
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));
}
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());
}
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());
}
Aggregations