Example usage for org.eclipse.jgit.api CheckoutCommand setForce

List of usage examples for org.eclipse.jgit.api CheckoutCommand setForce

Introduction

In this page you can find the example usage for org.eclipse.jgit.api CheckoutCommand setForce.

Prototype

@Deprecated
public CheckoutCommand setForce(boolean force) 

Source Link

Document

Specify to force the ref update in case of a branch switch.

Usage

From source file:com.verigreen.jgit.JGitOperator.java

License:Apache License

@Override
public String checkout(String branchName, boolean useBranchNameAsStartPoint, boolean createBranch,
        boolean useForce) {

    CheckoutCommand command = _git.checkout();
    command.setCreateBranch(createBranch);
    command.setForce(useForce);
    command.setName(branchName);//from   w  w  w  . ja v a2s .co  m
    if (useBranchNameAsStartPoint) {
        command.setStartPoint(REFS_REMOTES + branchName);
    }
    Ref ref = null;
    try {
        ref = command.call();
    } catch (Throwable e) {
        throw new RuntimeException(String.format("Failed to checkout branch [%s]", branchName), e);
    }

    return ref.getName();
}

From source file:net.erdfelt.android.sdkfido.git.internal.InternalGit.java

License:Apache License

@Override
public void checkoutBranch(String branchName) throws GitException {
    try {// w  w  w  .  j a v  a 2  s  .  co  m
        CheckoutCommand command = new Git(repo).checkout();
        command.setCreateBranch(false);
        command.setName(branchName);
        command.setForce(false);
        command.call();
    } catch (Throwable t) {
        throw new GitException(t.getMessage(), t);
    }
}

From source file:org.jboss.forge.addon.git.GitUtilsImpl.java

License:Open Source License

@Override
public Ref checkout(final Git git, final String remote, final boolean createBranch,
        final SetupUpstreamMode mode, final boolean force) throws GitAPIException {
    CheckoutCommand checkout = git.checkout();
    checkout.setCreateBranch(createBranch);
    checkout.setName(remote);/*from w  ww . j  a  va2 s .  com*/
    checkout.setForce(force);
    checkout.setUpstreamMode(mode);
    return checkout.call();
}

From source file:org.jboss.forge.addon.git.GitUtilsImpl.java

License:Open Source License

@Override
public Ref checkout(final Git git, final Ref localRef, final SetupUpstreamMode mode, final boolean force)
        throws GitAPIException {
    CheckoutCommand checkout = git.checkout();
    checkout.setName(Repository.shortenRefName(localRef.getName()));
    checkout.setForce(force);
    checkout.setUpstreamMode(mode);/* ww w  .ja  v  a 2 s.com*/
    return checkout.call();
}

From source file:org.jboss.forge.git.GitUtils.java

License:Open Source License

public static Ref checkout(final Git git, final String remote, final boolean createBranch,
        final SetupUpstreamMode mode, final boolean force) throws GitAPIException {
    CheckoutCommand checkout = git.checkout();
    checkout.setCreateBranch(createBranch);
    checkout.setName(remote);//from   ww w.  ja  v a 2  s .  c o m
    checkout.setForce(force);
    checkout.setUpstreamMode(mode);
    return checkout.call();
}

From source file:org.jboss.forge.git.GitUtils.java

License:Open Source License

public static Ref checkout(final Git git, final Ref localRef, final boolean createBranch,
        final SetupUpstreamMode mode, final boolean force) throws GitAPIException {
    CheckoutCommand checkout = git.checkout();
    checkout.setName(Repository.shortenRefName(localRef.getName()));
    checkout.setForce(force);
    checkout.setUpstreamMode(mode);//from www  . j  a v  a 2  s  .c om
    return checkout.call();
}

From source file:org.jplus.jenkins.plugin.git.GITRepositoryUtils.java

@Override
public void update() {
    try {//w ww  .j  a v a2 s . c  om
        LOGGER.debug("update git:" + repositoryPath);
        CheckoutCommand checkout = git.checkout();
        ObjectId resolve = repo.resolve("master");
        if (resolve == null) {
            checkout.setCreateBranch(true);
        }
        checkout.setForce(true);
        checkout.setStage(CheckoutCommand.Stage.THEIRS);
        checkout.setName("master");
        checkout.call();
        ResetCommand reset = git.reset();
        reset.setMode(ResetCommand.ResetType.HARD);
        reset.setRef("HEAD");
        reset.call();
        PullCommand pull = git.pull();
        pull.setRebase(true);
        pull.setRemote("origin");
        pull.setRemoteBranchName("master");
        pull.setStrategy(MergeStrategy.THEIRS);
        pull.call();
    } catch (Exception ex) {
        Logger.getLogger(GITRepositoryUtils.class.getName()).log(Level.SEVERE,
                "update git:" + repositoryPath + " error!!!", ex);
    }
}