|
2 | 2 | setlocal enabledelayedexpansion |
3 | 3 |
|
4 | 4 | REM Fetch the Bistro example assets into the desired assets directory. |
5 | | -REM Default target: assets\bistro at the repository root. |
| 5 | +REM Default target when run from attachments\simple_engine: Assets\bistro |
6 | 6 | REM Usage: |
7 | 7 | REM fetch_bistro_assets.bat [target-dir] |
8 | 8 | REM Example: |
|
12 | 12 | set REPO_HTTPS=https://github.com/gpx1000/bistro.git |
13 | 13 |
|
14 | 14 | if "%~1"=="" ( |
15 | | - set TARGET_DIR=Assets\bistro |
| 15 | + set "TARGET_DIR=Assets\bistro" |
16 | 16 | ) else ( |
17 | | - set TARGET_DIR=%~1 |
| 17 | + set "TARGET_DIR=%~1" |
18 | 18 | ) |
19 | 19 |
|
20 | | -REM Ensure parent directory exists |
21 | | -for %%I in ("%TARGET_DIR%") do set PARENT=%%~dpI |
22 | | -if not exist "%PARENT%" mkdir "%PARENT%" |
| 20 | +REM Ensure parent directory exists (avoid trailing backslash quoting issue by appending a dot) |
| 21 | +for %%I in ("%TARGET_DIR%") do set "PARENT=%%~dpI" |
| 22 | +if not exist "%PARENT%." mkdir "%PARENT%." |
23 | 23 |
|
24 | 24 | REM If directory exists and is a git repo, update it; otherwise clone it |
25 | 25 | if exist "%TARGET_DIR%\.git" ( |
26 | 26 | echo Updating existing bistro assets in %TARGET_DIR% |
27 | | - pushd "%TARGET_DIR%" |
| 27 | + pushd "%TARGET_DIR%" >nul 2>nul |
28 | 28 | git pull --ff-only |
29 | | - popd |
| 29 | + if errorlevel 1 ( |
| 30 | + echo ERROR: Failed to update repository at %TARGET_DIR%. |
| 31 | + popd >nul 2>nul |
| 32 | + endlocal & exit /b 1 |
| 33 | + ) |
| 34 | + popd >nul 2>nul |
30 | 35 | ) else ( |
31 | 36 | echo Cloning bistro assets into %TARGET_DIR% |
32 | 37 | REM Try SSH first; fall back to HTTPS on failure |
33 | | - git clone --depth 1 "%REPO_SSH%" "%TARGET_DIR%" 2>nul |
34 | | - if %ERRORLEVEL% neq 0 ( |
| 38 | + git clone --depth 1 "%REPO_SSH%" "%TARGET_DIR%" 1>nul 2>nul |
| 39 | + if errorlevel 1 ( |
35 | 40 | echo SSH clone failed, trying HTTPS |
36 | 41 | git clone --depth 1 "%REPO_HTTPS%" "%TARGET_DIR%" |
| 42 | + if errorlevel 1 ( |
| 43 | + echo ERROR: Failed to clone repository via HTTPS into %TARGET_DIR%. |
| 44 | + endlocal & exit /b 1 |
| 45 | + ) |
37 | 46 | ) |
38 | 47 | ) |
39 | 48 |
|
40 | | -REM If git-lfs is available, ensure LFS content is pulled |
41 | | -where git >nul 2>nul |
42 | | -if %ERRORLEVEL%==0 ( |
43 | | - pushd "%TARGET_DIR%" |
| 49 | +REM If git-lfs is available, ensure LFS content is pulled (ignore failures) |
| 50 | +if exist "%TARGET_DIR%\.git" ( |
| 51 | + pushd "%TARGET_DIR%" >nul 2>nul |
44 | 52 | git lfs version >nul 2>nul |
45 | | - if %ERRORLEVEL%==0 ( |
| 53 | + if not errorlevel 1 ( |
46 | 54 | git lfs install --local >nul 2>nul |
47 | | - git lfs pull |
| 55 | + git lfs pull || rem ignore |
48 | 56 | ) |
49 | | - popd |
| 57 | + popd >nul 2>nul |
50 | 58 | ) |
51 | 59 |
|
52 | 60 | echo Bistro assets ready at: %TARGET_DIR% |
53 | | -endlocal |
54 | | -exit /b 0 |
| 61 | +endlocal & exit /b 0 |
0 commit comments