From bece9f25d559cd2584adeeae8b217cfac270a530 Mon Sep 17 00:00:00 2001 From: Radu Nedelcu Date: Thu, 9 Oct 2025 10:23:30 +0000 Subject: [PATCH] [VCS] IJPL-73963 Abort/continue rebase notification should disappear when rebase is finished Merge-request: IJ-MR-177822 Merged-by: Radu Nedelcu [External] GitOrigin-RevId: 7b191f0e753e059bd14052396e10f8d269c00730 --- .../rebase/GitAbortRebaseProcess.java | 3 +- .../src/git4idea/rebase/GitRebaseProcess.java | 7 ++- .../rebase/GitSingleRepoRebaseTest.kt | 47 +++++++++++++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/rebase/GitAbortRebaseProcess.java b/plugins/git4idea/src/git4idea/rebase/GitAbortRebaseProcess.java index d77f6187ed5b..a3af207b781a 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitAbortRebaseProcess.java +++ b/plugins/git4idea/src/git4idea/rebase/GitAbortRebaseProcess.java @@ -14,6 +14,7 @@ import com.intellij.openapi.vcs.changes.ChangeListManagerEx; import com.intellij.vcs.log.Hash; import git4idea.DialogManager; import git4idea.GitActivity; +import git4idea.GitNotificationIdsHolder; import git4idea.GitUtil; import git4idea.commands.Git; import git4idea.commands.GitCommandResult; @@ -155,7 +156,7 @@ class GitAbortRebaseProcess { private void doAbort(final boolean rollback) { boolean[] success = new boolean[1]; - + myNotifier.hideAllNotificationsById(REBASE_STOPPED_ON_EDITING); new GitFreezingProcess(myProject, GitBundle.message("activity.name.rebase"), () -> { String activityName = GitBundle.message("activity.name.abort.command", GitBundle.message("abort.operation.rebase.name")); try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, activityName, GitActivity.Abort)) { diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java index d07f6d44e60d..fce513bf6385 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java @@ -246,6 +246,7 @@ public class GitRebaseProcess { return new GitRebaseStatus(GitRebaseStatus.Type.SUSPENDED); } LOG.debug("Successfully rebased " + repoName); + hideStoppedForEditingMessage(); return new GitSuccessfulRebase(); } else if (rebaseDetector.isDirtyTree() && customMode == null && !retryWhenDirty) { @@ -439,7 +440,11 @@ public class GitRebaseProcess { .setDisplayId(GitNotificationIdsHolder.REBASE_STOPPED_ON_EDITING) .addAction(CONTINUE_ACTION) .addAction(ABORT_ACTION); - myNotifier.notify(notification); + myNotifier.showNotificationAndHideExisting(notification); + } + + private void hideStoppedForEditingMessage() { + myNotifier.hideAllNotificationsById(GitNotificationIdsHolder.REBASE_STOPPED_ON_EDITING); } private void showRebaseContinueHasUnstagedChangesError(@NotNull GitRepository repository, diff --git a/plugins/git4idea/tests/git4idea/rebase/GitSingleRepoRebaseTest.kt b/plugins/git4idea/tests/git4idea/rebase/GitSingleRepoRebaseTest.kt index 467522dcb448..462f61e87ee4 100644 --- a/plugins/git4idea/tests/git4idea/rebase/GitSingleRepoRebaseTest.kt +++ b/plugins/git4idea/tests/git4idea/rebase/GitSingleRepoRebaseTest.kt @@ -592,7 +592,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() { assertSuccessfulRebaseNotification("Rebased feature on master") } - fun `test interactive rebase stopped for editing`() { + fun `test interactive rebase stopped for editing with continue`() { build { master { 0() @@ -617,16 +617,57 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() { rebaseInteractively() assertSuccessfulNotification("Rebase stopped for editing", "") + val successfulNotification = vcsNotifier.lastNotification assertEquals("The repository must be in the 'SUSPENDED' state", repo, repositoryManager.ongoingRebaseSpec!!.ongoingRebase) GitRebaseUtils.continueRebase(project) - assertSuccessfulRebaseNotification("Rebased feature on master") + + // IJPL-73963 + assertTrue(successfulNotification.isExpired) + repo.`assert feature rebased on master`() assertNoRebaseInProgress(repo) } - // IDEA-140568 + fun `test interactive rebase stopped for editing with abort`() { + build { + master { + 0() + 1() + } + feature(1) { + 2() + 3() + } + } + + git.setInteractiveRebaseEditor(TestGitImpl.InteractiveRebaseEditor({ + it.lines().mapIndexed { i, s -> + if (i != 0) s + else s.replace("pick", "edit") + }.joinToString(LineSeparator.getSystemLineSeparator().separatorString) + }, null)) + + refresh() + updateChangeListManager() + + rebaseInteractively() + + assertSuccessfulNotification("Rebase stopped for editing", "") + val successfulNotification = vcsNotifier.lastNotification + assertEquals("The repository must be in the 'SUSPENDED' state", repo, repositoryManager.ongoingRebaseSpec!!.ongoingRebase) + dialogManager.onMessage { Messages.YES } + GitRebaseUtils.abort(project, EmptyProgressIndicator()) + assertSuccessfulNotification("Abort rebase succeeded") + + // IJPL-73963 + assertTrue(successfulNotification.isExpired) + + assertNoRebaseInProgress(repo) + } + + // IDEA-140568 fun `test git help comments are ignored when parsing interactive rebase`() { makeCommit("initial.txt") repo.update()