Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions launch/core/platforms/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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).
Expand Down
13 changes: 12 additions & 1 deletion tests/runtime_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down