git, hg: Add "Amend" prefix to "Commit and Push" actions if amend mode is on (IDEA-224798)

GitOrigin-RevId: aac2e894811cb6e97a2942e7bc5762ec743c1698
This commit is contained in:
Konstantin Kolosovsky
2019-10-16 21:32:24 +00:00
committed by intellij-monorepo-bot
parent 8508588aa4
commit c4d4a3f899
3 changed files with 19 additions and 0 deletions
@@ -7,6 +7,11 @@ import com.intellij.openapi.vcs.actions.getContextCommitWorkflowHandler
import com.intellij.openapi.vcs.changes.CommitExecutor
import com.intellij.vcs.commit.CommitWorkflowHandler
fun AnActionEvent.getAmendCommitModePrefix(): String {
val isAmend = getContextCommitWorkflowHandler()?.amendCommitHandler?.isAmendCommitMode == true
return if (isAmend) "Amend " else ""
}
abstract class BaseCommitExecutorAction : DumbAwareAction() {
init {
isEnabledInModalContext = true
@@ -3,9 +3,16 @@
package git4idea.actions
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.vcs.changes.actions.BaseCommitExecutorAction
import com.intellij.openapi.vcs.changes.actions.getAmendCommitModePrefix
import git4idea.checkin.GitCommitAndPushExecutor
class GitCommitAndPushExecutorAction : BaseCommitExecutorAction() {
override fun update(e: AnActionEvent) {
super.update(e)
e.presentation.text = e.getAmendCommitModePrefix() + templateText
}
override val executorId: String = GitCommitAndPushExecutor.ID
}
@@ -1,9 +1,16 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.zmlx.hg4idea.action
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.vcs.changes.actions.BaseCommitExecutorAction
import com.intellij.openapi.vcs.changes.actions.getAmendCommitModePrefix
import org.zmlx.hg4idea.provider.commit.HgCommitAndPushExecutor
class HgCommitAndPushExecutorAction : BaseCommitExecutorAction() {
override fun update(e: AnActionEvent) {
super.update(e)
e.presentation.text = e.getAmendCommitModePrefix() + templateText
}
override val executorId: String = HgCommitAndPushExecutor.ID
}