Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-7880: Save latest commit message before showing Git Commit dialog #8004

Merged
merged 6 commits into from
Dec 26, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class CommitPresenter extends GitAuthActionPresenter
private final ProcessesPanelPresenter consolesPanelPresenter;

private Project project;
private String latestCommitMessage;

@Inject
public CommitPresenter(
Expand Down Expand Up @@ -118,7 +119,11 @@ public void showDialog(Project project) {
service
.log(project.getLocation(), null, -1, 1, false)
.then(
arg -> {
log -> {
final Revision revision = getFirst(log.getCommits(), null);
if (revision != null) {
latestCommitMessage = revision.getMessage();
}
if (diff.isEmpty()) {
showAskForAmendDialog();
} else {
Expand All @@ -140,6 +145,8 @@ public void showDialog(Project project) {
newFiles.addAll(status.getUntracked());
show(newFiles.stream().collect(joining("\nA\t", "A\t", "")));
});
} else {
notificationManager.notify(constant.logFailed(), FAIL, NOT_EMERGE_MODE);
}
});
})
Expand Down Expand Up @@ -267,30 +274,11 @@ public void onSelectionChanged(Path path, boolean isChecked) {

@Override
public void setAmendCommitMessage() {
service
.log(project.getLocation(), null, -1, -1, false)
.then(
log -> {
String message = "";
final Revision revision = getFirst(log.getCommits(), null);
if (revision != null) {
message = revision.getMessage();
}
CommitPresenter.this.view.setMessage(message);
CommitPresenter.this.view.setEnableCommitButton(!message.isEmpty());
})
.catchError(
error -> {
if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
dialogFactory
.createMessageDialog(
locale.commitTitle(), locale.initCommitWasNotPerformed(), null)
.show();
} else {
CommitPresenter.this.view.setMessage("");
notificationManager.notify(locale.logFailed(), FAIL, NOT_EMERGE_MODE);
}
});
if (latestCommitMessage == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just set focus to commit message text box

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added setting focus to message field on clicking the amend checkbox.

return;
}
view.setMessage(latestCommitMessage);
view.setEnableCommitButton(!latestCommitMessage.isEmpty());
}

private void onCommitSuccess(@NotNull final Revision revision) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public void onAmendValueChange(final ValueChangeEvent<Boolean> event) {
this.message.setValue("");
}
delegate.onValueChanged();
message.setFocus(true);
}

@Override
Expand Down