From 85c3cada0f40ad05e4c1fe677e562373b13b846d Mon Sep 17 00:00:00 2001 From: Slai_Agent_Runtime <294879785+huong8373tt-beep@users.noreply.github.com> Date: Fri, 25 Sep 2026 13:18:46 +0800 Subject: [PATCH] Fix-Windows-Git-tool-path-for-cygpath --- launch/core/platforms/windows.py | 11 +++++++++++ tests/runtime_test.py | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/launch/core/platforms/windows.py b/launch/core/platforms/windows.py index 28c146e..ba14a53 100644 --- a/launch/core/platforms/windows.py +++ b/launch/core/platforms/windows.py @@ -25,6 +25,14 @@ from docker.models.containers import Container +def build_windows_git_path_command() -> str: + """Build the PATH update used after installing Git for Windows.""" + return r'''$gitCmd = 'C:\Program Files\Git\cmd' +$gitBin = 'C:\Program Files\Git\bin' +$gitUsr = 'C:\Program Files\Git\usr\bin' +if (Test-Path $gitCmd) { $env:PATH = "$gitCmd;$gitBin;$gitUsr;$env:PATH" }''' + + class WindowsRuntime(LinuxRuntime): def __init__( @@ -289,6 +297,9 @@ def start_runtime_from_base_image( if (Test-Path $gitCmd) { $env:PATH = "$gitCmd;$gitBin;$env:PATH" } } ''' + # Git for Windows keeps cygpath in usr/bin. Add it unconditionally so + # preinstalled Git images get the same PATH as newly installed Git. + git_install_cmd += "\n" + build_windows_git_path_command() repo_clone_cmd = r'git config --global --add safe.directory "C:\testbed"; git init "C:\testbed"; cd "C:\testbed"; git remote add origin {url}; git fetch --depth 1 origin {base}; git reset --hard {base}'.format( url=url, base=base_commit ) diff --git a/tests/runtime_test.py b/tests/runtime_test.py index 809ec3d..4beb889 100644 --- a/tests/runtime_test.py +++ b/tests/runtime_test.py @@ -49,7 +49,10 @@ from launch.core.runtime import SetupRuntime from launch.core.platforms.linux import LinuxRuntime -from launch.core.platforms.windows import WindowsRuntime +from launch.core.platforms.windows import ( + WindowsRuntime, + build_windows_git_path_command, +) from launch.core.platforms.android import AndroidRuntime #from launch.core.platforms.macos import MacosRuntime @@ -66,6 +69,12 @@ class FakeSocket: pass +def test_windows_git_path_command_includes_usr_bin(): + command = build_windows_git_path_command() + assert r"$gitUsr = 'C:\Program Files\Git\usr\bin'" in command + assert "$gitUsr;$env:PATH" in command + + class FakeContainer: def __init__(self, sock: FakeSocket): self.sock = sock