git: extract gpg agent configuration action (IJPL-173525)

Follow-up: a6ec805357dd60578f2408a2ffaabadc53dad00e


(cherry picked from commit 771857ed0cafbdf74d9c82af47bd609a6bd58ea7)

IJ-CR-151739

GitOrigin-RevId: a537016fa7cae17945baf1b297696924d5281210
This commit is contained in:
Dmitry Zhuravlev
2024-12-16 20:36:00 +01:00
committed by intellij-monorepo-bot
parent f4380c4522
commit f45c905fe2
3 changed files with 28 additions and 0 deletions

View File

@@ -520,6 +520,8 @@
</group>
<reference ref="Git.Unshallow"/>
<action id="gpg.agent.configuration" class="git4idea.commit.signing.GpgAgentConfigurationAction"/>
</actions>
<extensions defaultExtensionNs="com.intellij">

View File

@@ -768,6 +768,8 @@ pgp.pinentry.configuration.proposal.title=GPG agent configuration
pgp.pinentry.configuration.proposal.message=Configure GPG Agent to support own pinentry
pgp.pinentry.configuration.proposal.configure=Configure
action.gpg.agent.configuration.text=Configure GPG Agent
gpg.pinentry.title=Unlock GPG Private Key
gpg.pinentry.default.description=Please enter the passphrase to unlock the GPG private key:

View File

@@ -0,0 +1,24 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.commit.signing
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAwareAction
import git4idea.config.GitExecutableManager
internal class GpgAgentConfigurationAction : DumbAwareAction() {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {
val project = e.project
e.presentation.isEnabledAndVisible = project != null
&& GpgAgentConfigurator.isEnabled(project, GitExecutableManager.getInstance().getExecutable(project))
&& !project.service<GpgAgentConfigurator>().isConfigured(project)
}
override fun actionPerformed(e: AnActionEvent) {
e.project?.service<GpgAgentConfigurator>()?.configure()
}
}