Example usage for org.eclipse.jgit.api StashCreateCommand setPerson

List of usage examples for org.eclipse.jgit.api StashCreateCommand setPerson

Introduction

In this page you can find the example usage for org.eclipse.jgit.api StashCreateCommand setPerson.

Prototype

public StashCreateCommand setPerson(PersonIdent person) 

Source Link

Document

Set the person to use as the author and committer in the commits made

Usage

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

License:Open Source License

@Override
protected boolean handlePost(RequestInfo requestInfo) throws ServletException {

    JSONObject requestPayload = requestInfo.getJSONRequest();
    HttpServletRequest request = requestInfo.request;
    HttpServletResponse response = requestInfo.response;
    Repository db = requestInfo.db;/*from   www . j  a  v  a  2s .c  om*/

    String indexMessage = requestPayload.optString(GitConstants.KEY_STASH_INDEX_MESSAGE);
    String workingDirectoryMessage = requestPayload.optString(GitConstants.KEY_STASH_WORKING_DIRECTORY_MESSAGE);
    boolean includeUntracked = requestPayload.optBoolean(GitConstants.KEY_STASH_INCLUDE_UNTRACKED, false);

    try {

        Git git = new Git(db);
        StashCreateCommand stashCreate = git.stashCreate();
        stashCreate.setPerson(new PersonIdent(db));
        stashCreate.setIncludeUntracked(includeUntracked);

        if (!indexMessage.isEmpty())
            stashCreate.setIndexMessage(indexMessage);

        if (!workingDirectoryMessage.isEmpty())
            stashCreate.setWorkingDirectoryMessage(workingDirectoryMessage);

        stashCreate.call();
        return true;

    } catch (Exception ex) {
        String msg = "An error occured for stash command.";
        return statusHandler.handleRequest(request, response,
                new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, ex));
    }
}