From b1616cf60ece18df54563b1aebb2dd0ae8e424fe Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 24 May 2017 18:50:50 +0300 Subject: [PATCH] Improve error message when trying to edit protected commit Use quotes, DRY --- .../src/git4idea/rebase/GitCommitEditingAction.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/git4idea/src/git4idea/rebase/GitCommitEditingAction.kt b/plugins/git4idea/src/git4idea/rebase/GitCommitEditingAction.kt index 8c96abaab940..e72313802f6f 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitCommitEditingAction.kt +++ b/plugins/git4idea/src/git4idea/rebase/GitCommitEditingAction.kt @@ -35,7 +35,6 @@ import git4idea.repo.GitRepository abstract class GitCommitEditingAction : DumbAwareAction() { private val COMMIT_NOT_IN_HEAD = "The commit is not in the current branch" - private val COMMIT_PUSHED_TO_PROTECTED = "The commit is already pushed to protected branch " override fun update(e: AnActionEvent) { super.update(e) @@ -82,7 +81,7 @@ abstract class GitCommitEditingAction : DumbAwareAction() { val protectedBranch = findProtectedRemoteBranch(repository, branches) if (protectedBranch != null) { e.presentation.isEnabled = false - e.presentation.description = COMMIT_PUSHED_TO_PROTECTED + protectedBranch + e.presentation.description = commitPushedToProtectedBranchError(protectedBranch) return } } @@ -108,7 +107,7 @@ abstract class GitCommitEditingAction : DumbAwareAction() { // and not if pushed to a protected branch val protectedBranch = findProtectedRemoteBranch(repository, branches) if (protectedBranch != null) { - Messages.showErrorDialog(project, COMMIT_PUSHED_TO_PROTECTED + protectedBranch, getFailureTitle()) + Messages.showErrorDialog(project, commitPushedToProtectedBranchError(protectedBranch), getFailureTitle()) return } } @@ -139,4 +138,7 @@ abstract class GitCommitEditingAction : DumbAwareAction() { map { it.nameForLocalOperations }. filter { branches.contains(it) }.firstOrNull() } + + private fun commitPushedToProtectedBranchError(protectedBranch: String) + = "The commit is already pushed to protected branch '$protectedBranch'" } \ No newline at end of file