mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
git: do not query GPG sign configuration by commands not related to sign
Follow-up: a32f415e4732699f6fd062a3b8bf902e99dccf13 (cherry picked from commit 69249b47ec79e297290980c15f0d0fae928feaf6) IJ-CR-149656 GitOrigin-RevId: 63229dd650f7941e9abbfad402f0ec4542d89784
This commit is contained in:
committed by
intellij-monorepo-bot
parent
60e0fff2fd
commit
bb24b2aacb
@@ -182,30 +182,33 @@ public final class GitHandlerAuthenticationManager implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void prepareGpgAgentAuth() {
|
||||
Project project = myHandler.project();
|
||||
VirtualFile root = myHandler.getExecutableContext().getRoot();
|
||||
if (project == null || root == null) {
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GpgAgentConfigurator.isEnabled(project, myHandler.myExecutable)) {
|
||||
GitCommand command = myHandler.getCommand();
|
||||
boolean isCommandSupported = command == GitCommand.COMMIT
|
||||
|| command == GitCommand.TAG
|
||||
|| command == GitCommand.MERGE
|
||||
|| command == GitCommand.CHERRY_PICK
|
||||
|| command == GitCommand.REBASE;
|
||||
if (!isCommandSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GpgAgentConfigurator.isEnabled(myProject, myHandler.myExecutable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GitRepository repo = GitRepositoryManager.getInstance(myProject).getRepositoryForRoot(root);
|
||||
if (repo == null) return;
|
||||
|
||||
GitCommand command = myHandler.getCommand();
|
||||
boolean needGpgSigning =
|
||||
(command == GitCommand.COMMIT || command == GitCommand.TAG || command == GitCommand.MERGE
|
||||
|| command == GitCommand.CHERRY_PICK || command == GitCommand.REBASE) &&
|
||||
GitGpgConfigUtilsKt.isGpgSignEnabledCached(repo);
|
||||
|
||||
if (needGpgSigning) {
|
||||
PinentryService.PinentryData pinentryData = PinentryService.getInstance(project).startSession();
|
||||
if (GitGpgConfigUtilsKt.isGpgSignEnabledCached(repo)) {
|
||||
PinentryService.PinentryData pinentryData = PinentryService.getInstance(myProject).startSession();
|
||||
if (pinentryData != null) {
|
||||
myHandler.addCustomEnvironmentVariable(PinentryService.PINENTRY_USER_DATA_ENV, pinentryData.toEnv());
|
||||
Disposer.register(myDisposable, () -> PinentryService.getInstance(project).stopSession());
|
||||
Disposer.register(myDisposable, () -> PinentryService.getInstance(myProject).stopSession());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import git4idea.commit.signing.GpgAgentPathsLocator.Companion.GPG_AGENT_CONF_FIL
|
||||
import git4idea.commit.signing.GpgAgentPathsLocator.Companion.GPG_HOME_DIR
|
||||
import git4idea.commit.signing.GpgAgentPathsLocator.Companion.PINENTRY_LAUNCHER_FILE_NAME
|
||||
import git4idea.config.GitExecutableManager
|
||||
import git4idea.repo.GitProjectConfigurationCache
|
||||
import git4idea.test.GitSingleRepoTest
|
||||
import org.junit.Assume.assumeTrue
|
||||
import java.io.BufferedWriter
|
||||
@@ -31,6 +32,7 @@ class PinentryExecutionTest : GitSingleRepoTest() {
|
||||
super.setUp()
|
||||
git("config commit.gpgSign true")
|
||||
git("config user.signingkey 0A46826A!")
|
||||
GitProjectConfigurationCache.getInstance(project).clearCache()
|
||||
val enabled = GpgAgentConfigurator.isEnabled(project, GitExecutableManager.getInstance().getExecutable(project))
|
||||
assumeTrue("GpgAgentConfigurator should be enabled", enabled);
|
||||
}
|
||||
@@ -134,7 +136,7 @@ class PinentryExecutionTest : GitSingleRepoTest() {
|
||||
val cmd = GeneralCommandLine(paths.gpgPinentryAppLauncherConfigPath)
|
||||
.withEnvironment(PinentryService.PINENTRY_USER_DATA_ENV, pinentryData.toEnv())
|
||||
|
||||
val output = object : CapturingProcessHandler.Silent(cmd) {
|
||||
val process = object : CapturingProcessHandler.Silent(cmd) {
|
||||
override fun createProcessAdapter(processOutput: ProcessOutput): CapturingProcessAdapter? {
|
||||
return object : CapturingProcessAdapter(processOutput) {
|
||||
val writer = BufferedWriter(OutputStreamWriter(process.outputStream, StandardCharsets.UTF_8))
|
||||
@@ -162,7 +164,12 @@ class PinentryExecutionTest : GitSingleRepoTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runProcess(10000, true).stdoutLines
|
||||
}.runProcess(10000, true)
|
||||
val output = process.stdoutLines
|
||||
var errLines = process.stderrLines
|
||||
if (errLines.isNotEmpty()) {
|
||||
LOG.warn("Error output: $errLines")
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
@@ -178,4 +185,8 @@ class PinentryExecutionTest : GitSingleRepoTest() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = logger<PinentryExecutionTest>()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user