Search in sources :

Example 11 with FetchOp

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

the class FetchOpTest method testFetchNoChanges.

@Test
public void testFetchNoChanges() throws Exception {
    prepareForFetch(true);
    // fetch from the remote
    FetchOp fetch = fetch();
    fetch.addRemote("origin").setAll(true).call();
    verifyFetch();
    // fetch again
    fetch.call();
    verifyFetch();
}
Also used : FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) Test(org.junit.Test)

Example 12 with FetchOp

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

the class FetchOpTest method testFetchNewCommitsWithShallowClone2.

@Test
public void testFetchNewCommitsWithShallowClone2() throws Exception {
    insertAndAdd(remoteGeogig.geogig, points1);
    RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("1").call();
    insertAndAdd(remoteGeogig.geogig, points2);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("2").call();
    insertAndAdd(remoteGeogig.geogig, points3);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("3").call();
    // clone the repository
    CloneOp clone = clone();
    clone.setDepth(2);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Checkout master and commit some changes
    remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(remoteGeogig.geogig, lines1);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("4").call();
    insertAndAdd(remoteGeogig.geogig, points1_modified);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("5").call();
    insertAndAdd(remoteGeogig.geogig, lines2);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("6").call();
    insertAndAdd(remoteGeogig.geogig, lines3);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("7").call();
    FetchOp fetch = fetch();
    // fetch.setDepth(2);
    fetch.call();
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/master").call();
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = Lists.newArrayList(logs);
    // Should have the previous 2 commits, plus all 4 new commits.
    assertEquals(6, logged.size());
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 13 with FetchOp

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

the class FetchOpTest method testFetchWithPruneAndBranchAdded.

@Test
public void testFetchWithPruneAndBranchAdded() throws Exception {
    prepareForFetch(true);
    // fetch from the remote
    FetchOp fetch = fetch();
    fetch.addRemote("origin").setAll(true).call();
    verifyFetch();
    // Remove a branch from the remote
    remoteGeogig.geogig.command(BranchDeleteOp.class).setName("Branch1").call();
    // Add another branch
    remoteGeogig.geogig.command(BranchCreateOp.class).setName("Branch2").call();
    // fetch again
    fetch = fetch();
    fetch.setPrune(true).call();
    verifyPrune();
    // Make sure the local repository has Branch2
    Optional<Ref> missing = localGeogig.geogig.command(RefParse.class).setName("refs/remotes/origin/Branch2").call();
    assertTrue(missing.isPresent());
}
Also used : Ref(org.locationtech.geogig.api.Ref) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) Test(org.junit.Test)

Example 14 with FetchOp

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

the class RemoteRepositoryTestCase method pull.

protected PullOp pull() {
    PullOp pull = spy(localGeogig.geogig.command(PullOp.class));
    FetchOp fetch = fetch();
    // when(pull.command(eq(FetchOp.class))).thenReturn(fetch);
    doReturn(fetch).when(pull).command(eq(FetchOp.class));
    LsRemote lsRemote = lsremote();
    // when(pull.command(eq(LsRemote.class))).thenReturn(lsRemote);
    doReturn(lsRemote).when(pull).command(eq(LsRemote.class));
    return pull;
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LsRemote(org.locationtech.geogig.api.plumbing.LsRemote)

Example 15 with FetchOp

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

the class RemoteRepositoryTestCase method fetch.

protected FetchOp fetch() {
    FetchOp remoteRepoFetch = spy(localGeogig.geogig.command(FetchOp.class));
    doReturn(Optional.of(remoteRepo)).when(remoteRepoFetch).getRemoteRepo(any(Remote.class), any(DeduplicationService.class));
    LsRemote lsRemote = lsremote();
    doReturn(lsRemote).when(remoteRepoFetch).command(eq(LsRemote.class));
    return remoteRepoFetch;
}
Also used : FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LsRemote(org.locationtech.geogig.api.plumbing.LsRemote) Remote(org.locationtech.geogig.api.Remote) LsRemote(org.locationtech.geogig.api.plumbing.LsRemote) DeduplicationService(org.locationtech.geogig.storage.DeduplicationService)

Aggregations

FetchOp (org.locationtech.geogig.api.porcelain.FetchOp)21 Test (org.junit.Test)15 CloneOp (org.locationtech.geogig.api.porcelain.CloneOp)6 RevCommit (org.locationtech.geogig.api.RevCommit)4 LsRemote (org.locationtech.geogig.api.plumbing.LsRemote)4 LogOp (org.locationtech.geogig.api.porcelain.LogOp)4 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)3 Remote (org.locationtech.geogig.api.Remote)2 SynchronizationException (org.locationtech.geogig.api.porcelain.SynchronizationException)2 TransferSummary (org.locationtech.geogig.api.porcelain.TransferSummary)2 ConsoleReader (jline.console.ConsoleReader)1 Context (org.locationtech.geogig.api.Context)1 Ref (org.locationtech.geogig.api.Ref)1 SendPack (org.locationtech.geogig.api.plumbing.SendPack)1 PullOp (org.locationtech.geogig.api.porcelain.PullOp)1 PushOp (org.locationtech.geogig.api.porcelain.PushOp)1 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)1 DeduplicationService (org.locationtech.geogig.storage.DeduplicationService)1 CommandContext (org.locationtech.geogig.web.api.CommandContext)1 CommandResponse (org.locationtech.geogig.web.api.CommandResponse)1