use of org.eclipse.egit.ui.internal.commit.CommitJob in project egit by eclipse.
the class StagingView method commit.
private void commit(boolean pushUpstream) {
if (!isCommitWithoutFilesAllowed()) {
MessageDialog md = new MessageDialog(getSite().getShell(), UIText.StagingView_committingNotPossible, null, UIText.StagingView_noStagedFiles, MessageDialog.ERROR, new String[] { IDialogConstants.CLOSE_LABEL }, 0);
md.open();
return;
}
if (!commitMessageComponent.checkCommitInfo())
return;
if (!UIUtils.saveAllEditors(currentRepository, UIText.StagingView_cancelCommitAfterSaving))
return;
String commitMessage = commitMessageComponent.getCommitMessage();
CommitOperation commitOperation = null;
try {
commitOperation = new CommitOperation(currentRepository, commitMessageComponent.getAuthor(), commitMessageComponent.getCommitter(), commitMessage);
} catch (CoreException e) {
Activator.handleError(UIText.StagingView_commitFailed, e, true);
return;
}
if (amendPreviousCommitAction.isChecked())
commitOperation.setAmending(true);
final boolean gerritMode = addChangeIdAction.isChecked();
commitOperation.setComputeChangeId(gerritMode);
PushMode pushMode = null;
if (pushUpstream) {
pushMode = gerritMode ? PushMode.GERRIT : PushMode.UPSTREAM;
}
Job commitJob = new CommitJob(currentRepository, commitOperation).setOpenCommitEditor(openNewCommitsAction.isChecked()).setPushUpstream(pushMode);
// don't allow to do anything as long as commit is in progress
enableAllWidgets(false);
commitJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
asyncExec(() -> {
enableAllWidgets(true);
if (event.getResult().isOK()) {
commitMessageText.setText(EMPTY_STRING);
}
});
}
});
schedule(commitJob, true);
CommitMessageHistory.saveCommitHistory(commitMessage);
clearCommitMessageToggles();
}
Aggregations