From c336fb91fdb49009cc3347722012c442f42ddb43 Mon Sep 17 00:00:00 2001 From: Slai_Agent_Runtime <294879785+huong8373tt-beep@users.noreply.github.com> Date: Thu, 24 Sep 2026 23:36:32 +0800 Subject: [PATCH] Fix Windows Git checkout symlink handling --- launch/core/platforms/windows.py | 15 ++++++++++++--- tests/runtime_test.py | 13 ++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/launch/core/platforms/windows.py b/launch/core/platforms/windows.py index 28c146e..3c6550c 100644 --- a/launch/core/platforms/windows.py +++ b/launch/core/platforms/windows.py @@ -25,6 +25,17 @@ from docker.models.containers import Container +def build_windows_repo_clone_command(url: str, base_commit: str) -> str: + """Build the Windows checkout command with Git symlink support enabled.""" + return ( + 'git config --global --add safe.directory "C:\\testbed"; ' + 'git config --global core.symlinks true; ' + 'git init "C:\\testbed"; ' + f'cd "C:\\testbed"; git remote add origin {url}; ' + f'git fetch --depth 1 origin {base_commit}; git reset --hard {base_commit}' + ) + + class WindowsRuntime(LinuxRuntime): def __init__( @@ -289,9 +300,7 @@ def start_runtime_from_base_image( if (Test-Path $gitCmd) { $env:PATH = "$gitCmd;$gitBin;$env:PATH" } } ''' - 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 - ) + repo_clone_cmd = build_windows_repo_clone_command(url, base_commit) session.preparation_commands.extend([git_install_cmd, repo_clone_cmd]) # 2) Ensure Git is installed (Chocolatey if possible; fallback to official silent installer). diff --git a/tests/runtime_test.py b/tests/runtime_test.py index 809ec3d..6928ed9 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_repo_clone_command, +) from launch.core.platforms.android import AndroidRuntime #from launch.core.platforms.macos import MacosRuntime @@ -66,6 +69,14 @@ class FakeSocket: pass +def test_windows_repo_clone_enables_git_symlinks(): + command = build_windows_repo_clone_command( + "https://github.com/example/project.git", "0123456789abcdef" + ) + assert "git config --global core.symlinks true" in command + assert "git reset --hard 0123456789abcdef" in command + + class FakeContainer: def __init__(self, sock: FakeSocket): self.sock = sock