List of usage examples for org.eclipse.jgit.api RevertCommand call
@Override public RevCommit call() throws NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, GitAPIException
Executes the revert command with all the options and parameters collected by the setter methods (e.g.
From source file:git_manager.tool.GitOperations.java
License:Open Source License
public void revertCommit() { RevertCommand revert = git.revert(); Iterable<RevCommit> logs = getLogs(); if (logs != null) { // revert.include(logs.iterator().next()); CommitCheckBox commitCheck = new CommitCheckBox(logs); if (commitCheck.logs.isEmpty()) { System.out.println("No commits selected to be undone"); } else {//w w w .ja v a2s . c om try { System.out.println("The following commits will be undone:"); for (RevCommit rc : commitCheck.logs) { revert.include(rc); System.out.println(" " + rc.getShortMessage()); } revert.call(); System.out.println("Done."); } catch (NoMessageException e) { e.printStackTrace(); } catch (UnmergedPathsException e) { e.printStackTrace(); } catch (ConcurrentRefUpdateException e) { e.printStackTrace(); } catch (WrongRepositoryStateException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } } } }
From source file:org.eclipse.egit.core.op.RevertCommitOperation.java
License:Open Source License
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor = m != null ? m : new NullProgressMonitor(); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { pm.beginTask("", 2); //$NON-NLS-1$ pm.subTask(MessageFormat.format(CoreText.RevertCommitOperation_reverting, commit.name())); RevertCommand command = new Git(repo).revert().include(commit); try { newHead = command.call(); reverted = command.getRevertedRefs(); result = command.getFailingResult(); } catch (GitAPIException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); }/*from w w w .jav a2 s.c om*/ pm.worked(1); ProjectUtil.refreshValidProjects(ProjectUtil.getValidOpenProjects(repo), new SubProgressMonitor(pm, 1)); pm.done(); } }; ResourcesPlugin.getWorkspace().run(action, monitor); }