@Override protected IStatus run(IProgressMonitor monitor) { RevCommit commit = null; try { commitOperation.execute(monitor); commit = commitOperation.getCommit(); CommitMessageComponentStateManager.deleteState(repository); RepositoryMapping mapping = RepositoryMapping.findRepositoryMapping(repository); if (mapping != null) mapping.fireRepositoryChanged(); } catch (CoreException e) { if (e.getCause() instanceof JGitInternalException) return Activator.createErrorStatus(e.getLocalizedMessage(), e.getCause()); return Activator.createErrorStatus(UIText.CommitAction_CommittingFailed, e); } finally { GitLightweightDecorator.refresh(); } if (commit != null) { if (openCommitEditor) openCommitEditor(commit); if (pushUpstream) pushUpstream(commit); } return Status.OK_STATUS; }
private static RevCommit commit( IProject project, String commitMessage, Repository repository, IProgressMonitor monitor) throws CoreException { Assert.isLegal(project != null, "Could not commit project. No project provided"); Assert.isLegal( repository != null, MessageFormat.format( "Could not commit. Project \"{0}\" is not connected to a repository (call #connect(project, repository) first)", project.getName())); /** TODO: add capability to commit selectively */ UserConfig userConfig = getUserConfig(repository); CommitOperation op = new CommitOperation( null, null, null, getFormattedUser(userConfig.getAuthorName(), userConfig.getAuthorEmail()), getFormattedUser(userConfig.getCommitterName(), userConfig.getCommitterEmail()), commitMessage); op.setCommitAll(true); op.setRepository(repository); op.execute(monitor); return op.getCommit(); }