Package org.locationtech.geogig.api.porcelain

Examples of org.locationtech.geogig.api.porcelain.CheckoutResult


        Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
        geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId()))
                .call();

        CheckoutResult result;
        result = geogig.command(CheckoutOp.class).setSource("branch1").call();
        assertEquals(c2.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();
        assertFalse(c4.getTreeId().equals(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());

        Iterator<RevCommit> log = geogig.command(LogOp.class).call();
View Full Code Here


        Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
        geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId()))
                .setSquashMessage("squashed commit").call();

        CheckoutResult result;
        result = geogig.command(CheckoutOp.class).setSource("branch1").call();
        assertEquals(c2.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();
        assertFalse(c4.getTreeId().equals(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());

        Iterator<RevCommit> log = geogig.command(LogOp.class).call();
View Full Code Here

        Optional<Ref> master = geogig.command(RefParse.class).setName("master").call();

        geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId()))
                .setOnto(Suppliers.ofInstance(master.get().getObjectId())).call();

        CheckoutResult result;
        result = geogig.command(CheckoutOp.class).setSource("branch1").call();
        assertEquals(c3.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();
        assertFalse(c4.getTreeId().equals(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());

        Iterator<RevCommit> log = geogig.command(LogOp.class).call();
View Full Code Here

        try {
            final ConsoleReader console = cli.getConsole();
            String branchOrCommit = (branchOrStartPoint.size() > 0 ? branchOrStartPoint.get(0)
                    : null);

            CheckoutResult result = geogig.command(CheckoutOp.class).setForce(force)
                    .setSource(branchOrCommit).addPaths(paths).setOurs(ours).setTheirs(theirs)
                    .call();

            switch (result.getResult()) {
            case CHECKOUT_LOCAL_BRANCH:
                console.println("Switched to branch '" + result.getNewRef().localName() + "'");
                break;
            case CHECKOUT_REMOTE_BRANCH:
                console.println("Branch '" + result.getNewRef().localName()
                        + "' was set up to track remote branch '" + result.getNewRef().localName()
                        + "' from " + result.getRemoteName() + ".");
                console.println("Switched to a new branch '" + result.getNewRef().localName() + "'");
                break;
            case UPDATE_OBJECTS:
                console.println("Objects in the working tree were updated to the specifed version.");
                break;
            case DETACHED_HEAD:
                console.println("You are in 'detached HEAD' state. HEAD is now at "
                        + result.getOid().toString().substring(0, 7) + "...");
                break;
            default:
                break;
            }
        } catch (CheckoutException e) {
View Full Code Here

        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());
    }
View Full Code Here

        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());
    }
View Full Code Here

    public void testCheckoutPathFilter() throws Exception {
        ObjectId points1Id = insertAndAdd(points1);
        geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        insert(points1_modified);

        CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call();

        Optional<RevTree> workTree = geogig.command(RevObjectParse.class)
                .setObjectId(result.getNewTree()).call(RevTree.class);

        Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get())
                .setChildPath("Points/Points.1").call();

        assertEquals(points1Id, nodeRef.get().getNode().getObjectId());
View Full Code Here

        ObjectId lines1Id = insertAndAdd(lines1);
        geogig.command(CommitOp.class).setMessage("commit 1").call();
        insert(points1_modified);
        insert(lines2);
        Collection<String> paths = Arrays.asList("Points/Points.1", "Lines");
        CheckoutResult result = geogig.command(CheckoutOp.class).addPaths(paths).call();
        Optional<RevTree> workTree = geogig.command(RevObjectParse.class)
                .setObjectId(result.getNewTree()).call(RevTree.class);
        Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get())
                .setChildPath("Points/Points.1").call();

        assertEquals(points1Id, nodeRef.get().getNode().getObjectId());
View Full Code Here

        RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit 2").call();
        insertAndAdd(points3);
        geogig.command(CommitOp.class).setMessage("commit 3").call();
        insert(points1_modified);

        CheckoutResult result = geogig.command(CheckoutOp.class)
                .setSource(c2.getTreeId().toString()).addPath("Points").call();

        Optional<RevTree> workTree = geogig.command(RevObjectParse.class)
                .setObjectId(result.getNewTree()).call(RevTree.class);
        Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get())
                .setChildPath("Points/Points.1").call();

        assertEquals(points1Id, nodeRef.get().getNode().getObjectId());
View Full Code Here

    public void testCheckoutBranchWithForceOptionAndChangesInTheIndex() throws Exception {
        insertAndAdd(points1);
        RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
        Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").call();
        insertAndAdd(points2);
        CheckoutResult result = geogig.command(CheckoutOp.class).setSource("branch1")
                .setForce(true).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());
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.porcelain.CheckoutResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.