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
11 changes: 11 additions & 0 deletions launch/core/platforms/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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
)
Expand Down
11 changes: 10 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_git_path_command,
)
from launch.core.platforms.android import AndroidRuntime
#from launch.core.platforms.macos import MacosRuntime

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