Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.SymRef


        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't revert.");
        Preconditions.checkState(currHead.get() instanceof SymRef,
                "Can't revert from detached HEAD");
        final SymRef headRef = (SymRef) currHead.get();
        Preconditions.checkState(!headRef.getObjectId().equals(ObjectId.NULL),
                "HEAD has no history.");
        currentBranch = headRef.getTarget();
        revertHead = currHead.get().getObjectId();

        Preconditions.checkArgument(!(continueRevert && abort),
                "Cannot continue and abort at the same time");
View Full Code Here


        long changeset = Long.parseLong(line);
        return changeset;
    }

    private File getBranchTrackingFile(GeoGIG geogig) throws IOException {
        final SymRef head = getHead(geogig);
        final String branch = head.getTarget();
        final URL geogigDirUrl = geogig.command(ResolveGeogigDir.class).call().get();
        File repoDir;
        try {
            repoDir = new File(geogigDirUrl.toURI());
        } catch (URISyntaxException e) {
View Full Code Here

        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't reset.");
        Preconditions
                .checkState(currHead.get() instanceof SymRef, "Can't reset from detached HEAD");
        final SymRef headRef = (SymRef) currHead.get();

        final String currentBranch = headRef.getTarget();

        if (commit == null) {
            commit = Suppliers.ofInstance(currHead.get().getObjectId());
        }
View Full Code Here

        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't squash.");
        Preconditions.checkState(currHead.get() instanceof SymRef,
                "Can't squash from detached HEAD");
        final SymRef headRef = (SymRef) currHead.get();
        final String currentBranch = headRef.getTarget();

        Preconditions.checkState(index().isClean() && workingTree().isClean(),
                "You must have a clean working tree and index to perform a squash.");

        Optional<ObjectId> ancestor = command(FindCommonAncestor.class).setLeft(since)
View Full Code Here

            // pull current branch
            final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
            Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't pull.");
            Preconditions.checkState(currHead.get() instanceof SymRef,
                    "Can't pull from detached HEAD");
            final SymRef headRef = (SymRef) currHead.get();
            final String currentBranch = Ref.localName(headRef.getTarget());

            refSpecs.add(currentBranch + ":" + currentBranch);
        }

        for (String refspec : refSpecs) {
            String[] refs = refspec.split(":");
            Preconditions.checkArgument(refs.length < 3,
                    "Invalid refspec, please use [+]<remoteref>[:<localref>].");

            boolean force = refspec.length() > 0 && refspec.charAt(0) == '+';
            String remoteref = refs[0].substring(force ? 1 : 0);
            Optional<Ref> sourceRef = findRemoteRef(remoteref);
            if (!sourceRef.isPresent()) {
                continue;
            }

            String destinationref = "";
            if (refs.length == 2) {
                destinationref = refs[1];
            } else {
                // pull into current branch
                final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
                Preconditions.checkState(currHead.isPresent(),
                        "Repository has no HEAD, can't pull.");
                Preconditions.checkState(currHead.get() instanceof SymRef,
                        "Can't pull from detached HEAD");
                final SymRef headRef = (SymRef) currHead.get();
                destinationref = headRef.getTarget();
            }

            Optional<Ref> destRef = command(RefParse.class).setName(destinationref).call();
            if (destRef.isPresent()) {
                if (destRef.get().getObjectId().equals(sourceRef.get().getObjectId())
View Full Code Here

        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions
                .checkState(currHead.isPresent(), "Repository has no HEAD, can't cherry pick.");
        Preconditions.checkState(currHead.get() instanceof SymRef,
                "Can't cherry pick from detached HEAD");
        final SymRef headRef = (SymRef) currHead.get();

        Preconditions.checkState(index().isClean() && workingTree().isClean(),
                "You must have a clean working tree and index to perform a cherry pick.");

        getProgressListener().started();

        Preconditions.checkArgument(repository.commitExists(commit),
                "Commit could not be resolved: %s.", commit);
        RevCommit commitToApply = repository.getCommit(commit);

        ObjectId headId = headRef.getObjectId();

        ObjectId parentCommitId = ObjectId.NULL;
        if (commitToApply.getParentIds().size() > 0) {
            parentCommitId = commitToApply.getParentIds().get(0);
        }
View Full Code Here

                    }
                }
            }
            if (noCommit) {
                final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
                SymRef headRef = (SymRef) currHead.get();
                RevCommit headCommit = repository().getCommit(headRef.getObjectId());
                command(UpdateRef.class).setName(Ref.MERGE_HEAD).setNewValue(commits.get(0)).call();
                // TODO:how to store multiple ids when octopus merge
                command(UpdateRef.class).setName(Ref.ORIG_HEAD).setNewValue(headCommit.getId())
                        .call();
                mergeCommit = headCommit;
View Full Code Here

            if (branchName.size() == 1) {
                Optional<Ref> headRef = geogig.command(RefParse.class).setName(Ref.HEAD).call();
                geogig.command(BranchRenameOp.class).setNewName(branchName.get(0)).setForce(force)
                        .call();
                if (headRef.isPresent()) {
                    SymRef ref = (SymRef) headRef.get();
                    console.println("renamed branch '"
                            + ref.getTarget().substring(Ref.HEADS_PREFIX.length()) + "' to '"
                            + branchName.get(0) + "'");
                }
            } else {
                geogig.command(BranchRenameOp.class).setOldName(branchName.get(0))
                        .setNewName(branchName.get(1)).setForce(force).call();
View Full Code Here

            } else {
                // checkout the head
                final Optional<Ref> currRemoteHead = command(RefParse.class).setName(
                        Ref.REMOTES_PREFIX + remote.getName() + "/" + Ref.HEAD).call();
                if (currRemoteHead.isPresent() && currRemoteHead.get() instanceof SymRef) {
                    final SymRef remoteHeadRef = (SymRef) currRemoteHead.get();
                    final String currentBranch = Ref.localName(remoteHeadRef.getTarget());
                    command(CheckoutOp.class).setForce(true).setSource(currentBranch).call();
                } else {
                    // just leave at default; should be master since we just initialized the repo.
                }
View Full Code Here

                            .error("Repository has no HEAD, can't pull."));
                } else if (!(currHead.get() instanceof SymRef)) {
                    context.setResponseContent(CommandResponse
                            .error("Can't pull from detached HEAD"));
                }
                final SymRef headRef = (SymRef) currHead.get();
                destinationref = headRef.getTarget();
            }

            Optional<Ref> destRef = geogig.command(RefParse.class).setName(destinationref).call();
            final RevCommit theirs = context.getGeoGIG().getRepository()
                    .getCommit(sourceRef.get().getObjectId());
View Full Code Here

TOP

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

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.