use of org.locationtech.geogig.api.RevCommit 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);
}
use of org.locationtech.geogig.api.RevCommit 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);
}
use of org.locationtech.geogig.api.RevCommit 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);
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class GeogigTransactionTest method testCommitUpdatesRemoteRefs.
@Test
public void testCommitUpdatesRemoteRefs() throws Exception {
// make a commit
insertAndAdd(points1);
RevCommit headCommit = geogig.command(CommitOp.class).call();
geogig.command(RemoteAddOp.class).setName("upstream").setURL("http://test.com/geogig/upstream").call();
final String remoteRef = "refs/remotes/upstream/master";
final String unchangedRemoteRef = "refs/remotes/upstream/testbranch";
Ref remoteHead = geogig.command(UpdateRef.class).setName(remoteRef).setNewValue(headCommit.getId()).call().get();
assertEquals(headCommit.getId(), remoteHead.getObjectId());
geogig.command(UpdateRef.class).setName(unchangedRemoteRef).setNewValue(headCommit.getId()).call().get();
// start a transaction
GeogigTransaction tx = geogig.command(TransactionBegin.class).call();
// make a commit
insertAndAdd(tx, points2);
RevCommit newcommit = tx.command(CommitOp.class).call();
// upadte remote
Ref txRemoteHead = tx.command(UpdateRef.class).setName(remoteRef).setNewValue(newcommit.getId()).call().get();
assertEquals(newcommit.getId(), txRemoteHead.getObjectId());
// commit transaction
tx.commit();
txRemoteHead = geogig.command(RefParse.class).setName(remoteRef).call().get();
assertEquals(newcommit.getId(), txRemoteHead.getObjectId());
txRemoteHead = geogig.command(RefParse.class).setName(unchangedRemoteRef).call().get();
assertEquals(headCommit.getId(), txRemoteHead.getObjectId());
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class GeogigTransactionTest method testTransaction.
@Test
public void testTransaction() throws Exception {
LinkedList<RevCommit> expectedMain = new LinkedList<RevCommit>();
LinkedList<RevCommit> expectedTransaction = new LinkedList<RevCommit>();
// make a commit
insertAndAdd(points1);
RevCommit commit = geogig.command(CommitOp.class).call();
expectedMain.addFirst(commit);
expectedTransaction.addFirst(commit);
// start a transaction
GeogigTransaction t = geogig.command(TransactionBegin.class).call();
// perform a commit in the transaction
insertAndAdd(t, points2);
commit = t.command(CommitOp.class).call();
expectedTransaction.addFirst(commit);
// Verify that the base repository is unchanged
Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
List<RevCommit> logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedMain, logged);
// Verify that the transaction has the commit
logs = t.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedTransaction, logged);
// Commit the transaction
geogig.command(TransactionEnd.class).setTransaction(t).setRebase(true).call();
// Verify that the base repository has the changes from the transaction
logs = geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedTransaction, logged);
}
Aggregations