Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.Ref


        insertAndAdd(points1ModifiedB);
        insertAndAdd(points2);
        geogig.command(CommitOp.class).call();

        geogig.command(CheckoutOp.class).setSource("master").call();
        Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
        try {
            geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId()))
                    .call();
            fail();
        } catch (MergeConflictsException e) {
            assertTrue(e.getMessage().contains("conflict"));
        }
View Full Code Here


        insertAndAdd(points1ModifiedB);
        insertAndAdd(points2);
        geogig.command(CommitOp.class).call();

        geogig.command(CheckoutOp.class).setSource("master").call();
        Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
        try {
            geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId()))
                    .call();
            fail();
        } catch (MergeConflictsException e) {
            assertTrue(e.getMessage().contains("conflict"));
        }
View Full Code Here

        // | |
        // o | - Lines 1 added
        // |/
        // o - master - HEAD - Merge commit

        Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
        MergeReport mergeReport = geogig.command(MergeOp.class)
                .addCommit(Suppliers.ofInstance(branch1.getObjectId()))
                .setMessage("My merge message.").call();

        RevCommit mergeCommit = mergeReport.getMergeCommit();

        Iterator<RevCommit> iterator = logOp.call();
View Full Code Here

        // | |
        // o | - Lines 1 added
        // |/
        // o - master - HEAD - Merge commit

        Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
        MergeReport mergeReport = geogig.command(MergeOp.class)
                .addCommit(Suppliers.ofInstance(branch1.getObjectId()))
                .setMessage("My merge message.").call();

        RevCommit mergeCommit = mergeReport.getMergeCommit();

        Iterator<RevCommit> iterator = logOp.addPath(pointsName + "/" + idP2).call();
View Full Code Here

        Optional<Ref> head = getCommandLocator(null).command(RefParse.class).setName(Ref.HEAD)
                .call();
        if (!head.isPresent()) {
            return null;
        }
        Ref headRef = head.get();
        if (!(headRef instanceof SymRef)) {
            return null;
        }
        String refName = ((SymRef) headRef).getTarget();
        Preconditions.checkState(refName.startsWith(Ref.HEADS_PREFIX));
View Full Code Here

            Optional<Ref> target = getRef(storedValue);
            if (!target.isPresent()) {
                throw new RuntimeException("target '" + storedValue
                        + "' was not present for symref " + name + " -> '" + storedValue + "'");
            }
            Ref resolved = new SymRef(name, target.get());
            return Optional.of(resolved);
        }
        ObjectId objectId = ObjectId.valueOf(storedValue);
        return Optional.of(new Ref(name, objectId));
    }
View Full Code Here

        ImmutableSet.Builder<Ref> refs = new ImmutableSet.Builder<Ref>();
        for (String refName : refDatabase().getAll().keySet()) {
            Optional<Ref> ref = command(RefParse.class).setName(refName).call();
            if (ref.isPresent() && filter.apply(ref.get())) {
                Ref accepted = ref.get();
                refs.add(accepted);
            }
        }
        return refs.build();
    }
View Full Code Here

            // Update refs
            for (Ref ref : changedRefs) {
                if (!ref.getName().startsWith(Ref.REFS_PREFIX)) {
                    continue;
                }
                Ref updatedRef = ref;

                Optional<Ref> repoRef = command(RefParse.class).setName(ref.getName()).call();
                if (repoRef.isPresent() && repositoryChanged(repoRef.get())) {
                    if (rebase) {
                        // Try to rebase
                        transaction.command(CheckoutOp.class).setSource(ref.getName())
                                .setForce(true).call();
                        try {
                            transaction.command(RebaseOp.class)
                                    .setUpstream(Suppliers.ofInstance(repoRef.get().getObjectId()))
                                    .call();
                        } catch (RebaseConflictsException e) {
                            Throwables.propagate(e);
                        }
                        updatedRef = transaction.command(RefParse.class).setName(ref.getName())
                                .call().get();
                    } else {
                        // sync transactions have to use merge to prevent divergent history
                        transaction.command(CheckoutOp.class).setSource(ref.getName())
                                .setForce(true).call();
                        try {
                            transaction.command(MergeOp.class)
                                    .setAuthor(authorName.orNull(), authorEmail.orNull())
                                    .addCommit(Suppliers.ofInstance(repoRef.get().getObjectId()))
                                    .call();
                        } catch (NothingToCommitException e) {
                            // The repo commit is already in our history, this is a fast
                            // forward.
                        }
                        updatedRef = transaction.command(RefParse.class).setName(ref.getName())
                                .call().get();
                    }
                }

                LOGGER.debug(String.format("commit %s %s -> %s", ref.getName(), ref.getObjectId(),
                        updatedRef.getObjectId()));

                command(UpdateRef.class).setName(ref.getName())
                        .setNewValue(updatedRef.getObjectId()).call();

                if (currentBranch.equals(ref.getName())) {
                    // Update HEAD, WORK_HEAD and STAGE_HEAD
                    command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(ref.getName()).call();
                    command(UpdateRef.class).setName(Ref.WORK_HEAD)
                            .setNewValue(updatedRef.getObjectId()).call();
                    command(UpdateRef.class).setName(Ref.STAGE_HEAD)
                            .setNewValue(updatedRef.getObjectId()).call();
                }
            }

            // TODO: What happens if there are unstaged or staged changes in the repository when
            // a transaction is committed?
View Full Code Here

            ImmutableList<Ref> refs = ggit.command(BranchListOp.class).setRemotes(remotes).call();
            ImmutableList<RevTag> tags = ggit.command(TagListOp.class).call();

            // Print out HEAD first
            final Ref currentHead = ggit.command(RefParse.class).setName(Ref.HEAD).call().get();
            if (!currentHead.getObjectId().equals(ObjectId.NULL)) {
                w.write(currentHead.getName() + " ");
                if (currentHead instanceof SymRef) {
                    w.write(((SymRef) currentHead).getTarget());
                }
                w.write(" ");
                w.write(currentHead.getObjectId().toString());
                w.write("\n");
            }

            // Print out the local branches
            for (Ref ref : refs) {
View Full Code Here

        // | |
        // o | - Lines 1 added
        // |/
        // o - master - HEAD - Merge commit

        Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
        MergeReport mergeReport = geogig.command(MergeOp.class)
                .addCommit(Suppliers.ofInstance(branch1.getObjectId()))
                .setMessage("My merge message.").call();

        RevTree mergedTree = repo.getTree(mergeReport.getMergeCommit().getTreeId());

        String path = appendChild(pointsName, points2.getIdentifier().getID());
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.Ref

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.