Example usage for org.eclipse.jgit.api PullCommand setStrategy

List of usage examples for org.eclipse.jgit.api PullCommand setStrategy

Introduction

In this page you can find the example usage for org.eclipse.jgit.api PullCommand setStrategy.

Prototype

public PullCommand setStrategy(MergeStrategy strategy) 

Source Link

Document

Set the @{code MergeStrategy}

Usage

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

@Override
public void update() {
    try {//from   ww  w . j  a  v a 2s . 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);
    }
}