[cherry-pick] show staging area with preset message for commit when changelists are disabled

GitOrigin-RevId: 67d437970773c35a2048af7599ebd4e53ed0ec8a
This commit is contained in:
Julia Beliaeva
2020-10-21 21:16:57 +00:00
committed by intellij-monorepo-bot
parent 1d675bb47a
commit 73604de7bd
3 changed files with 33 additions and 1 deletions
@@ -7,6 +7,7 @@ import com.intellij.notification.Notification
import com.intellij.notification.NotificationListener
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.NlsSafe
@@ -32,6 +33,7 @@ import git4idea.commands.GitSimpleEventDetector.Event.CHERRY_PICK_CONFLICT
import git4idea.commands.GitSimpleEventDetector.Event.LOCAL_CHANGES_OVERWRITTEN_BY_CHERRY_PICK
import git4idea.commands.GitUntrackedFilesOverwrittenByOperationDetector
import git4idea.i18n.GitBundle
import git4idea.index.showStagingArea
import git4idea.merge.GitConflictResolver
import git4idea.merge.GitDefaultMergeDialogCustomizer
import git4idea.repo.GitRepository
@@ -180,7 +182,12 @@ class GitApplyChangesProcess(private val project: Project,
changeList: LocalChangeList,
successfulCommits: MutableList<VcsFullCommitDetails>,
alreadyPicked: MutableList<VcsFullCommitDetails>): Boolean {
if (!changeListManager.areChangeListsEnabled()) return false
if (!changeListManager.areChangeListsEnabled()) {
runInEdt {
showStagingArea(project, commitMessage)
}
return false
}
val actualList = changeListManager.getChangeList(changeList.id)
if (actualList == null) {
@@ -11,8 +11,11 @@ import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerListener
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentProvider
import com.intellij.ui.content.Content
import com.intellij.util.NotNullFunction
import com.intellij.util.concurrency.annotations.RequiresEdt
import com.intellij.util.ui.UIUtil
import com.intellij.vcs.commit.CommitTabTitleUpdater
import com.intellij.vcsUtil.VcsUtil
import git4idea.index.GitStageContentProvider.Companion.STAGING_AREA_TAB_NAME
import git4idea.index.ui.GitStagePanel
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
@@ -71,4 +74,22 @@ class GitStageContentVisibilityPredicate : NotNullFunction<Project, Boolean> {
class GitStageDisplayNameSupplier : Supplier<String> {
override fun get(): @Nls String = VcsBundle.message("tab.title.commit")
}
@RequiresEdt
fun showStagingArea(project: Project, commitMessage: String) {
showStagingArea(project) {
it.setCommitMessage(commitMessage)
}
}
private fun showStagingArea(project: Project, consumer: (GitStagePanel) -> Unit) {
val toolWindow = ChangesViewContentManager.getToolWindowFor(project, STAGING_AREA_TAB_NAME) ?: return
toolWindow.activate({
val contentManager = ChangesViewContentManager.getInstance(project) as ChangesViewContentManager
val content = contentManager.findContents { it.tabName == STAGING_AREA_TAB_NAME }.singleOrNull() ?: return@activate
contentManager.setSelectedContent(content, true)
(content.component as? GitStagePanel)?.let(consumer)
}, true)
}
@@ -155,6 +155,10 @@ internal class GitStagePanel(private val tracker: GitStageTracker, isEditorDiffP
}
}
internal fun setCommitMessage(commitMessage: String) {
commitPanel.commitMessage.setCommitMessage(commitMessage)
}
override fun dispose() {
}