mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CherryPicker: better notification about local changes preventing the cherry-pick
This commit is contained in:
@@ -100,8 +100,12 @@ public class CherryPicker {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (localChangesOverwrittenDetector.hasHappened()) {
|
||||
notifyError("Your local changes would be overwritten by cherry-pick.<br/>Commit your changes or stash them to proceed.",
|
||||
commit, successfulCommits);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// including localChangesOverwrittenDetector.hasHappened() - no special handler for now
|
||||
notifyError(result.getErrorOutputAsHtmlString(), commit, successfulCommits);
|
||||
return false;
|
||||
}
|
||||
@@ -112,7 +116,7 @@ public class CherryPicker {
|
||||
|
||||
private void notifyConflictWarning(GitCommit commit, List<GitCommit> successfulCommits) {
|
||||
String description = commitDetails(commit);
|
||||
description += getSuccessfulCommitDetailsIfAny(successfulCommits, description);
|
||||
description += getSuccessfulCommitDetailsIfAny(successfulCommits);
|
||||
myPlatformFacade.getNotificator(myProject).notifyWeakWarning("Cherry-picked with conflicts", description);
|
||||
}
|
||||
|
||||
@@ -158,12 +162,13 @@ public class CherryPicker {
|
||||
|
||||
private void notifyError(@NotNull String content, @NotNull GitCommit failedCommit, @NotNull List<GitCommit> successfulCommits) {
|
||||
String description = "Cherry-pick failed for " + commitDetails(failedCommit) + "<br/>" + content;
|
||||
description += getSuccessfulCommitDetailsIfAny(successfulCommits, description);
|
||||
description += getSuccessfulCommitDetailsIfAny(successfulCommits);
|
||||
myPlatformFacade.getNotificator(myProject).notifyError("Cherry-pick failed", description);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getSuccessfulCommitDetailsIfAny(@NotNull List<GitCommit> successfulCommits, @NotNull String description) {
|
||||
private static String getSuccessfulCommitDetailsIfAny(@NotNull List<GitCommit> successfulCommits) {
|
||||
String description = "";
|
||||
if (!successfulCommits.isEmpty()) {
|
||||
description += "<br/>However it succeeded for the following " + StringUtil.pluralize("commit", successfulCommits.size()) + ": <br/>";
|
||||
description = getCommitsDetails(successfulCommits);
|
||||
@@ -187,7 +192,7 @@ public class CherryPicker {
|
||||
|
||||
@NotNull
|
||||
private static String commitDetails(@NotNull GitCommit commit) {
|
||||
return commit.getShortHash().toString() + " " + commit.getSubject();
|
||||
return commit.getShortHash().toString() + " \"" + commit.getSubject() + "\"";
|
||||
}
|
||||
|
||||
private void refreshChangedFiles(@NotNull Collection<FilePath> filePaths) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package git4idea.cherrypick
|
||||
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.notification.NotificationType
|
||||
import git4idea.history.browser.CherryPicker
|
||||
import git4idea.history.browser.GitCommit
|
||||
@@ -76,13 +75,15 @@ Otherwise, please use 'git reset'
|
||||
void "dirty tree, conflicting with commit, then show error"() {
|
||||
myGit.registerOperationExecutors(new SimpleErrorOperationExecutor(CHERRY_PICK, LOCAL_CHANGES_OVERWRITTEN_BY_CHERRY_PICK))
|
||||
|
||||
invokeCherryPick(commit())
|
||||
def commit = commit()
|
||||
invokeCherryPick(commit)
|
||||
|
||||
assertNotCherryPicked()
|
||||
assertOnlyDefaultChangelist()
|
||||
assertNotificationShown(new Notification(TEST_NOTIFICATION_GROUP, "Cherry-pick failed",
|
||||
"Your local changes to some files would be overwritten by cherry-pick. View them",
|
||||
NotificationType.ERROR))
|
||||
assertNotificationShown("Cherry-pick failed",
|
||||
"Cherry-pick failed for ${notificationContent(commit)}" +
|
||||
"Your local changes would be overwritten by cherry-pick.<br/>Commit your changes or stash them to proceed.",
|
||||
NotificationType.ERROR)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -119,7 +119,7 @@ hint: and commit the result with 'git commit'
|
||||
}
|
||||
|
||||
String notificationContent(GitCommit commit) {
|
||||
"${commit.shortHash.toString()} ${commit.subject}"
|
||||
"${commit.shortHash.toString()} \"${commit.subject}\""
|
||||
}
|
||||
|
||||
String notificationContent(GitCommit... commits) {
|
||||
|
||||
Reference in New Issue
Block a user