Example usage for org.eclipse.jgit.api Git cherryPick

List of usage examples for org.eclipse.jgit.api Git cherryPick

Introduction

In this page you can find the example usage for org.eclipse.jgit.api Git cherryPick.

Prototype

public CherryPickCommand cherryPick() 

Source Link

Document

Return a command object to execute a cherry-pick command

Usage

From source file:org.eclipse.egit.ui.internal.history.command.CherryPickHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    RevCommit commit = (RevCommit) getSelection(getPage()).getFirstElement();
    RevCommit newHead;//from  w w  w.java  2 s .c  om
    Repository repo = getRepository(event);

    CherryPickCommand cherryPick;
    Git git = new Git(repo);
    try {
        cherryPick = git.cherryPick().include(commit.getId());
        newHead = cherryPick.call();
    } catch (Exception e) {
        throw new ExecutionException(CoreText.CherryPickOperation_InternalError, e);
    }
    if (newHead == null)
        throw new ExecutionException(CoreText.CherryPickOperation_Failed);
    return null;
}

From source file:org.eclipse.orion.server.git.servlets.GitCommitHandlerV1.java

License:Open Source License

private boolean cherryPick(HttpServletRequest request, HttpServletResponse response, Repository db,
        String commitToCherryPick) throws ServletException, JSONException {
    try {/*from   ww w  .j a v  a2s.  c  o m*/
        ObjectId objectId = db.resolve(commitToCherryPick);
        Git git = new Git(db);
        CherryPickResult cherryPickResult = git.cherryPick().include(objectId).call();
        JSONObject result = new JSONObject();
        result.put(GitConstants.KEY_RESULT, cherryPickResult.getStatus().name());
        OrionServlet.writeJSONResponse(request, response, result);
        return true;
    } catch (IOException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR,
                HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occured when cherry-picking.", e));
    } catch (GitAPIException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR,
                HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occured when cherry-picking.", e));
    } catch (JGitInternalException e) {
        return statusHandler.handleRequest(request, response,
                new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "An error occured when cherry-picking.", e.getCause()));
    }
}

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

License:Open Source License

@Override
public void cherryPick(final Git repo, Ref commit) throws GitAPIException {
    repo.cherryPick().include(commit).call();
}

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

License:Open Source License

public static void cherryPick(final Git repo, Ref commit) throws GitAPIException {
    repo.cherryPick().include(commit).call();
}