use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class CheckoutOpTest method testCheckoutBranch.
@Test
public void testCheckoutBranch() throws Exception {
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
final Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
final Ref branch2 = geogig.command(BranchCreateOp.class).setName("branch2").call();
insertAndAdd(lines1);
final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
final Ref branch3 = geogig.command(BranchCreateOp.class).setName("branch3").call();
CheckoutResult result;
result = geogig.command(CheckoutOp.class).setSource("branch1").call();
assertEquals(c1.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch1.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
result = geogig.command(CheckoutOp.class).setSource("branch2").call();
assertEquals(c2.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch2.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
result = geogig.command(CheckoutOp.class).setSource("branch3").call();
assertEquals(c3.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch3.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class BlameOpTest method testBlameChangedByLastCommit.
@Test
public void testBlameChangedByLastCommit() throws Exception {
insertAndAdd(points1);
geogig.command(CommitOp.class).call();
insertAndAdd(points1_modified);
RevCommit secondCommit = geogig.command(CommitOp.class).call();
String path = NodeRef.appendChild(pointsName, idP1);
BlameReport report = geogig.command(BlameOp.class).setPath(path).call();
Map<String, ValueAndCommit> changes = report.getChanges();
assertEquals(3, changes.size());
Collection<ValueAndCommit> commits = changes.values();
for (ValueAndCommit valueAndCommit : commits) {
assertEquals(secondCommit, valueAndCommit.commit);
}
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class CheckSparsePathTest method testCheckSparsePath.
@Test
public void testCheckSparsePath() throws Exception {
// Create the following revision graph
// o - commit1
// |\
// | o - commit2
// | |
// | o - commit3
// | |\
// | | o - commit4
// | | |\
// | | | o - commit5 (sparse)
// | | | |
// | | o | - commit6
// | | |/
// | | o - commit7
// | |
// o | - commit8
// | |
// | o - commit9
// |/
// o - commit10
insertAndAdd(points1);
RevCommit commit1 = geogig.command(CommitOp.class).setMessage("commit1").call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
insertAndAdd(points2);
RevCommit commit2 = geogig.command(CommitOp.class).setMessage("commit2").call();
insertAndAdd(points3);
RevCommit commit3 = geogig.command(CommitOp.class).setMessage("commit3").call();
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch2").call();
insertAndAdd(lines1);
RevCommit commit4 = geogig.command(CommitOp.class).setMessage("commit4").call();
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch3").call();
insertAndAdd(poly1);
RevCommit commit5 = geogig.command(CommitOp.class).setMessage("commit5").call();
geogig.getRepository().graphDatabase().setProperty(commit5.getId(), GraphDatabase.SPARSE_FLAG, "true");
geogig.command(CheckoutOp.class).setSource("branch2").call();
insertAndAdd(poly2);
RevCommit commit6 = geogig.command(CommitOp.class).setMessage("commit6").call();
RevCommit commit7 = geogig.command(MergeOp.class).setMessage("commit7").addCommit(Suppliers.ofInstance(commit5.getId())).call().getMergeCommit();
geogig.command(CheckoutOp.class).setSource("branch1").call();
insertAndAdd(lines3);
RevCommit commit9 = geogig.command(CommitOp.class).setMessage("commit9").call();
// checkout master
geogig.command(CheckoutOp.class).setSource("master").call();
insertAndAdd(lines2);
RevCommit commit8 = geogig.command(CommitOp.class).setMessage("commit8").call();
RevCommit commit10 = geogig.command(MergeOp.class).setMessage("commit10").addCommit(Suppliers.ofInstance(commit9.getId())).call().getMergeCommit();
CheckSparsePath command = geogig.command(CheckSparsePath.class);
assertTrue(command.setStart(commit7.getId()).setEnd(commit1.getId()).call());
assertFalse(command.setStart(commit6.getId()).setEnd(commit1.getId()).call());
assertTrue(command.setStart(commit5.getId()).setEnd(commit2.getId()).call());
assertFalse(command.setStart(commit10.getId()).setEnd(commit1.getId()).call());
assertFalse(command.setStart(commit10.getId()).setEnd(commit3.getId()).call());
assertFalse(command.setStart(commit8.getId()).setEnd(commit1.getId()).call());
assertFalse(command.setStart(commit4.getId()).setEnd(commit2.getId()).call());
assertFalse(command.setStart(commit7.getId()).setEnd(commit5.getId()).call());
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class BlameOpTest method testBlameChangedByASingleCommit.
@Test
public void testBlameChangedByASingleCommit() throws Exception {
insertAndAdd(points1);
RevCommit firstCommit = geogig.command(CommitOp.class).call();
String path = NodeRef.appendChild(pointsName, idP1);
BlameReport report = geogig.command(BlameOp.class).setPath(path).call();
Map<String, ValueAndCommit> changes = report.getChanges();
assertEquals(3, changes.size());
Collection<ValueAndCommit> commits = changes.values();
for (ValueAndCommit valueAndCommit : commits) {
assertEquals(firstCommit, valueAndCommit.commit);
}
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class BranchCreateOpTest method testCreateBranchWithTheSameNameAsExistingBranchAndForce.
@Test
public void testCreateBranchWithTheSameNameAsExistingBranchAndForce() throws Exception {
insertAndAdd(points1);
geogig.command(CommitOp.class).setMessage("Commit1").call();
geogig.command(BranchCreateOp.class).setName("branch1").call();
insertAndAdd(points2);
RevCommit newCommit = geogig.command(CommitOp.class).setMessage("Commit2").call();
geogig.command(BranchCreateOp.class).setName("branch1").setForce(true).call();
Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call();
assertTrue(branch1.isPresent());
assertEquals(branch1.get().getObjectId(), newCommit.getId());
}
Aggregations