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

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

Introduction

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

Prototype

public CheckoutCommand setStage(Stage stage) 

Source Link

Document

When checking out the index, check out the specified stage (ours or theirs) for unmerged paths.

Usage

From source file:org.archicontribs.modelrepository.grafico.MergeConflictHandler.java

License:Open Source License

private void checkout(Git git, Stage stage, List<String> paths) throws IOException, GitAPIException {
    CheckoutCommand checkoutCommand = git.checkout();
    checkoutCommand.setStage(stage);
    checkoutCommand.addPaths(paths);//from w ww  .j  a va  2  s .  c  om
    checkoutCommand.call();
}

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

@Override
public void update() {
    try {/*from w  ww.  j a va2 s . c o  m*/
        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);
    }
}