[eel-vcs] IJPL-204860 eliminate hacky wsl-only fix, add GitExecutable.isRemote

(cherry picked from commit 2d57034b2d993da860941cb6ac9001654e5899df)

IJ-CR-180951

GitOrigin-RevId: 00198b29345ca30910f4d21bfd05097006c48679
This commit is contained in:
Mihail Buryakov
2025-11-12 14:13:10 +00:00
committed by intellij-monorepo-bot
parent 3ce5cdd82a
commit f93f5c52d3
3 changed files with 15 additions and 17 deletions
@@ -29,10 +29,6 @@ public class GitScriptGenerator extends ScriptGeneratorImpl {
}
}
public GitScriptGenerator(@Nullable WSLDistribution wslDistribution) {
myWSLDistribution = wslDistribution;
}
@Override
protected @NotNull String getJavaExecutablePath() {
if (myWSLDistribution != null) {
@@ -25,7 +25,6 @@ import com.intellij.openapi.util.io.NioFiles
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.vcs.VcsException
import com.intellij.platform.ide.impl.wsl.WslEelDescriptor
import com.intellij.platform.util.coroutines.flow.debounceBatch
import com.intellij.util.application
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
@@ -55,7 +54,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import org.intellij.lang.annotations.Language
import org.jetbrains.annotations.VisibleForTesting
import java.io.IOException
import java.nio.file.InvalidPathException
@@ -75,14 +73,17 @@ internal class GpgAgentConfigurator(private val project: Project, private val cs
@JvmStatic
fun isEnabled(project: Project, executable: GitExecutable): Boolean =
(Registry.`is`("git.commit.gpg.signing.enable.embedded.pinentry", false) || application.isUnitTestMode)
&& (SystemInfo.isUnix || (executable !is GitExecutable.Unknown && !executable.isLocal))
&& (isRemDevOrWsl(executable) || isLocalUnix(executable))
&& signingIsEnabledInAnyRepo(project)
private fun isUnitTestModeOnUnix(): Boolean =
SystemInfo.isUnix && application.isUnitTestMode
private fun isLocalUnix(executable: GitExecutable): Boolean =
executable.isLocal && SystemInfo.isUnix
private fun isRemDevOrWsl(executable: GitExecutable): Boolean =
AppMode.isRemoteDevHost() || (executable !is GitExecutable.Unknown && !executable.isLocal)
AppMode.isRemoteDevHost() || executable.isRemote
// do not configure Gpg Agent for roots without commit.gpgSign and user.signingkey enabled
private fun signingIsEnabledInAnyRepo(project: Project): Boolean = GitRepositoryManager.getInstance(project)
@@ -366,15 +367,7 @@ internal class PinentryShellScriptLauncherGenerator(val executable: GitExecutabl
}
fun getCommandLine(): String {
val gitScriptGenerator = when (executable) {
is GitExecutable.Eel -> {
GitScriptGenerator((executable.eel.descriptor as? WslEelDescriptor)?.distribution)
}
else -> {
GitScriptGenerator(executable)
}
}
return gitScriptGenerator.addParameters(*getCommandLineParameters()).commandLine(PinentryApp::class.java, false)
return GitScriptGenerator(executable).addParameters(*getCommandLineParameters()).commandLine(PinentryApp::class.java, false)
}
private fun getScriptTemplate(fallbackPinentryPath: String?): String {
@@ -71,6 +71,7 @@ sealed class GitExecutable {
abstract val id: String
abstract val exePath: String
abstract val isLocal: Boolean
open val isRemote: Boolean get() = !isLocal
/**
* Convert an absolute file path into a form that can be passed into executable arguments.
@@ -162,6 +163,9 @@ sealed class GitExecutable {
override fun getLocaleEnv(): Map<String, String> = VcsLocaleHelper.getDefaultLocaleEnvironmentVars("git")
}
/**
* Ideally, can represent any git executable, either local or remote. Actual instantiation depends on the feature flags enabled.
*/
data class Eel(override val exePath: @NonNls String, val eel: EelApi) : GitExecutable() {
private val delegate = Local(exePath)
@@ -197,6 +201,10 @@ sealed class GitExecutable {
}
}
/**
* Legacy option of handling wsl git.
* Now [Eel] is used for representing wsl git (as well as git inside docker and any other non-demdev remote git).
*/
data class Wsl(
override val exePath: String,
val distribution: WSLDistribution,
@@ -300,6 +308,7 @@ sealed class GitExecutable {
data class Unknown(override val id: String, override val exePath: String, val errorMessage: @Nls String) : GitExecutable() {
override val isLocal: Boolean = false
override val isRemote: Boolean = false
override fun toString(): String = "$id: $exePath"
override fun getModificationTime(): Long {