List of usage examples for org.eclipse.jgit.api StashCreateCommand call
@Override public RevCommit call() throws GitAPIException
Stash the contents on the working directory and index in separate commits and reset to the current HEAD commit.
From source file:org.eclipse.egit.core.op.StashCreateOperation.java
License:Open Source License
public void execute(IProgressMonitor monitor) throws CoreException { IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { try { StashCreateCommand command = Git.wrap(repository).stashCreate(); if (message != null) { command.setIndexMessage(message); command.setWorkingDirectoryMessage(message); }/*ww w . j a v a2 s .c om*/ commit = command.call(); } catch (JGitInternalException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); } catch (GitAPIException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); } finally { if (commit != null) repository.notifyIndexChanged(); pm.done(); } } }; ResourcesPlugin.getWorkspace().run(action, monitor != null ? monitor : new NullProgressMonitor()); }
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;// w w w .j a v a 2 s . 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)); } }