mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[git] Cleanup conflict notification on cherry-pick/revert aborted
GitOrigin-RevId: 2945893918c7aa00504efe5072ba13fe5bab6301
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f1be858574
commit
777cc6554b
@@ -0,0 +1,44 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package git4idea
|
||||
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.notification.NotificationAction
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.util.NlsContexts.NotificationContent
|
||||
import com.intellij.openapi.vcs.VcsNotifier
|
||||
import com.intellij.vcs.log.VcsCommitMetadata
|
||||
import com.intellij.vcs.log.util.VcsUserUtil
|
||||
import git4idea.GitApplyChangesProcess.ConflictResolver
|
||||
import git4idea.actions.GitAbortOperationAction
|
||||
import git4idea.i18n.GitBundle
|
||||
import git4idea.repo.GitRepository
|
||||
import org.jetbrains.annotations.Nls
|
||||
|
||||
internal class ApplyChangesConflictNotification(
|
||||
operationName: @Nls String,
|
||||
description: @NotificationContent String,
|
||||
commit: VcsCommitMetadata,
|
||||
repository: GitRepository,
|
||||
abortCommand: GitAbortOperationAction,
|
||||
) : Notification(
|
||||
VcsNotifier.importantNotification().displayId,
|
||||
GitBundle.message("apply.changes.operation.performed.with.conflicts", operationName.capitalize()),
|
||||
description,
|
||||
NotificationType.WARNING,
|
||||
) {
|
||||
init {
|
||||
setDisplayId(GitNotificationIdsHolder.APPLY_CHANGES_CONFLICTS)
|
||||
|
||||
addAction(NotificationAction.createSimple(GitBundle.message("apply.changes.unresolved.conflicts.notification.resolve.action.text")) {
|
||||
val hash = commit.id.toShortString()
|
||||
val commitAuthor = VcsUserUtil.getShortPresentation(commit.author)
|
||||
val commitMessage = commit.subject
|
||||
ConflictResolver(repository.project, repository.root, hash, commitAuthor, commitMessage, operationName).mergeNoProceedInBackground()
|
||||
})
|
||||
|
||||
addAction(NotificationAction.create(GitBundle.message("apply.changes.unresolved.conflicts.notification.abort.action.text",
|
||||
operationName.capitalize())) {
|
||||
abortCommand.performInBackground(repository)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import com.intellij.dvcs.DvcsUtil
|
||||
import com.intellij.dvcs.DvcsUtil.getShortRepositoryName
|
||||
import com.intellij.history.ActivityId
|
||||
import com.intellij.history.LocalHistory
|
||||
import com.intellij.notification.NotificationAction
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.application.runInEdt
|
||||
@@ -419,28 +417,12 @@ internal class GitApplyChangesProcess(
|
||||
commit: VcsCommitMetadata,
|
||||
successfulCommits: List<VcsCommitMetadata>,
|
||||
) {
|
||||
val title = GitBundle.message("apply.changes.operation.performed.with.conflicts", operationName.capitalize())
|
||||
|
||||
var description = commitDetails(commit)
|
||||
description += UIUtil.BR + GitBundle.message("apply.changes.unresolved.conflicts.text")
|
||||
description += getSuccessfulCommitDetailsIfAny(successfulCommits)
|
||||
|
||||
val notification = VcsNotifier.importantNotification()
|
||||
.createNotification(title, description, NotificationType.WARNING)
|
||||
.setDisplayId(GitNotificationIdsHolder.APPLY_CHANGES_CONFLICTS)
|
||||
.addAction(NotificationAction.createSimple(GitBundle.message("apply.changes.unresolved.conflicts.notification.resolve.action.text")) {
|
||||
val hash = commit.id.toShortString()
|
||||
val commitAuthor = VcsUserUtil.getShortPresentation(commit.author)
|
||||
val commitMessage = commit.subject
|
||||
ConflictResolver(project, repository.root, hash, commitAuthor, commitMessage, operationName).mergeNoProceedInBackground()
|
||||
})
|
||||
.addAction(NotificationAction.create(GitBundle.message("apply.changes.unresolved.conflicts.notification.abort.action.text",
|
||||
operationName.capitalize())) { _, notification ->
|
||||
if (abortCommand.performInBackground(repository)) {
|
||||
notification.expire()
|
||||
}
|
||||
})
|
||||
VcsNotifier.getInstance(project).notify(notification)
|
||||
val description = commitDetails(commit) +
|
||||
UIUtil.BR +
|
||||
GitBundle.message("apply.changes.unresolved.conflicts.text") +
|
||||
getSuccessfulCommitDetailsIfAny(successfulCommits)
|
||||
VcsNotifier.getInstance(project)
|
||||
.notify(ApplyChangesConflictNotification(operationName, description, commit, repository, abortCommand))
|
||||
}
|
||||
|
||||
private fun notifyCommitCancelled(commit: VcsCommitMetadata, successfulCommits: List<VcsCommitMetadata>) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.CommonBundle
|
||||
import com.intellij.dvcs.DvcsUtil
|
||||
import com.intellij.dvcs.repo.Repository
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.notification.NotificationsManager
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.runBackgroundableTask
|
||||
import com.intellij.openapi.ui.Messages
|
||||
@@ -13,6 +14,7 @@ import com.intellij.openapi.vcs.VcsNotifier
|
||||
import com.intellij.openapi.vcs.changes.ChangeListData
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerEx
|
||||
import com.intellij.openapi.vcs.update.RefreshVFsSynchronously
|
||||
import git4idea.ApplyChangesConflictNotification
|
||||
import git4idea.DialogManager
|
||||
import git4idea.GitActivity
|
||||
import git4idea.GitNotificationIdsHolder.Companion.CHERRY_PICK_ABORT_FAILED
|
||||
@@ -67,6 +69,11 @@ internal abstract class GitAbortOperationAction(
|
||||
runBackgroundableTask(GitBundle.message("abort.operation.progress.title", operationNameCapitalised), repository.project) { indicator ->
|
||||
doAbort(repository, indicator)
|
||||
}
|
||||
|
||||
NotificationsManager.getNotificationsManager()
|
||||
.getNotificationsOfType(ApplyChangesConflictNotification::class.java, repository.project)
|
||||
.forEach { it.expire() }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user