From c4d4a3f89981801595684f65b0666f6990df4cfa Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Thu, 17 Oct 2019 00:20:37 +0300 Subject: [PATCH] git, hg: Add "Amend" prefix to "Commit and Push" actions if amend mode is on (IDEA-224798) GitOrigin-RevId: aac2e894811cb6e97a2942e7bc5762ec743c1698 --- .../vcs/changes/actions/BaseCommitExecutorAction.kt | 5 +++++ .../src/git4idea/actions/GitCommitAndPushExecutorAction.kt | 7 +++++++ .../zmlx/hg4idea/action/HgCommitAndPushExecutorAction.kt | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BaseCommitExecutorAction.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BaseCommitExecutorAction.kt index 1c1637991c77..915579234140 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BaseCommitExecutorAction.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BaseCommitExecutorAction.kt @@ -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 diff --git a/plugins/git4idea/src/git4idea/actions/GitCommitAndPushExecutorAction.kt b/plugins/git4idea/src/git4idea/actions/GitCommitAndPushExecutorAction.kt index 2fcc5daaaa81..90d6510e4bf5 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCommitAndPushExecutorAction.kt +++ b/plugins/git4idea/src/git4idea/actions/GitCommitAndPushExecutorAction.kt @@ -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 } \ No newline at end of file diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommitAndPushExecutorAction.kt b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommitAndPushExecutorAction.kt index 0d5c6d5c2a91..c1a0075181fe 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommitAndPushExecutorAction.kt +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommitAndPushExecutorAction.kt @@ -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 } \ No newline at end of file