mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-115318 Clicking "amend" shouldn't revert what user has typed
* Remember the initial commit message. * On "amend" select: substitute commit message with the message of the previous commit, only if user hasn't modified the initial message. * On "amend" deselect: substitute commit message with the initially saved one, only if user hasn't modified the amended message.
This commit is contained in:
@@ -680,20 +680,26 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
|
||||
myAmend.setToolTipText(GitBundle.getString("commit.amend.tooltip"));
|
||||
myPanel.add(myAmend, c);
|
||||
|
||||
myPreviousMessage = myCheckinPanel.getCommitMessage();
|
||||
|
||||
myAmend.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myAmend.isSelected()) {
|
||||
if (myAmendedMessage != null) { // checkbox is selected not the first time
|
||||
substituteCommitMessage(myAmendedMessage);
|
||||
}
|
||||
else {
|
||||
loadMessageInModalTask(project);
|
||||
if (myPreviousMessage.equals(myCheckinPanel.getCommitMessage())) { // if user has already typed something, don't revert it
|
||||
if (myAmendedMessage == null) {
|
||||
loadMessageInModalTask(project);
|
||||
}
|
||||
else { // checkbox is selected not the first time
|
||||
substituteCommitMessage(myAmendedMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
myAmendedMessage = myCheckinPanel.getCommitMessage(); // save if user accidentally deselected amended message
|
||||
myCheckinPanel.setCommitMessage(myPreviousMessage);
|
||||
// there was the amended message, but user has changed it => not reverting
|
||||
if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) {
|
||||
myCheckinPanel.setCommitMessage(myPreviousMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -710,6 +716,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
|
||||
}, "Reading commit message...", false, project);
|
||||
if (!StringUtil.isEmptyOrSpaces(messageFromGit)) {
|
||||
substituteCommitMessage(messageFromGit);
|
||||
myAmendedMessage = messageFromGit;
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
|
||||
Reference in New Issue
Block a user