From 4275405b82c90389d3a9f5e32ccdb52fb8be4101 Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Mon, 6 Oct 2025 14:00:22 +0200 Subject: [PATCH] [eel-vcs][git] autodetect WSL distribution type for Git distribution (IJPL-210178) GitOrigin-RevId: ff9ed8e0bef41e5379bb05b2d9634371da4d15f1 --- plugins/git4idea/BUILD.bazel | 2 ++ plugins/git4idea/intellij.vcs.git.iml | 1 + plugins/git4idea/resources/intellij.vcs.git.xml | 1 + .../git4idea/config/GitExecutableFileTester.java | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/BUILD.bazel b/plugins/git4idea/BUILD.bazel index 709fc75da186..53ccf6af3c3a 100644 --- a/plugins/git4idea/BUILD.bazel +++ b/plugins/git4idea/BUILD.bazel @@ -106,6 +106,7 @@ jvm_library( "//platform/eel-provider", "//platform/eel", "//platform/platform-impl/recentProjects", + "//platform/platform-impl/eel:ide-impl-wsl", ], exports = [ "//platform/dvcs-api:vcs-dvcs", @@ -219,6 +220,7 @@ jvm_library( "//platform/eel-provider", "//platform/eel", "//platform/platform-impl/recentProjects", + "//platform/platform-impl/eel:ide-impl-wsl", ], exports = [ "//platform/dvcs-api:vcs-dvcs", diff --git a/plugins/git4idea/intellij.vcs.git.iml b/plugins/git4idea/intellij.vcs.git.iml index 821a09b7978e..2e5b418e886b 100644 --- a/plugins/git4idea/intellij.vcs.git.iml +++ b/plugins/git4idea/intellij.vcs.git.iml @@ -123,5 +123,6 @@ + \ No newline at end of file diff --git a/plugins/git4idea/resources/intellij.vcs.git.xml b/plugins/git4idea/resources/intellij.vcs.git.xml index 3e023a0d8385..cfde9bdeeafb 100644 --- a/plugins/git4idea/resources/intellij.vcs.git.xml +++ b/plugins/git4idea/resources/intellij.vcs.git.xml @@ -7,6 +7,7 @@ + diff --git a/plugins/git4idea/src/git4idea/config/GitExecutableFileTester.java b/plugins/git4idea/src/git4idea/config/GitExecutableFileTester.java index 5559b17cce0e..d9b53cae1981 100644 --- a/plugins/git4idea/src/git4idea/config/GitExecutableFileTester.java +++ b/plugins/git4idea/src/git4idea/config/GitExecutableFileTester.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.config; import com.intellij.execution.wsl.WSLDistribution; @@ -11,7 +11,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.platform.eel.EelApi; +import com.intellij.platform.eel.EelOsFamily; import com.intellij.platform.eel.provider.EelNioBridgeServiceKt; +import com.intellij.platform.eel.provider.LocalEelDescriptor; +import com.intellij.platform.ide.impl.wsl.WslEelDescriptor; import com.intellij.util.concurrency.AppJavaExecutorUtil; import git4idea.commands.Git; import git4idea.commands.GitCommand; @@ -149,6 +152,13 @@ class GitExecutableFileTester { workingDirectory = Path.of(distribution.getWindowsPath("/")); } else if (executable instanceof GitExecutable.Eel) { EelApi eelApi = ((GitExecutable.Eel)executable).getEel(); + if (eelApi.getDescriptor() instanceof WslEelDescriptor) { + WSLDistribution distribution = ((WslEelDescriptor) eelApi.getDescriptor()).getDistribution(); + type = distribution.getVersion() == 1 ? GitVersion.Type.WSL1 : GitVersion.Type.WSL2; + } + else if (eelApi.getDescriptor() instanceof LocalEelDescriptor && eelApi.getPlatform().getOsFamily().equals(EelOsFamily.Posix)) { + type = GitVersion.Type.UNIX; + } workingDirectory = EelNioBridgeServiceKt.asNioPath(eelApi.getUserInfo().getHome()); } @@ -198,4 +208,4 @@ class GitExecutableFileTester { return myFileLastModifiedTimestamp; } } -} \ No newline at end of file +}