deer-flow/scripts/run-with-git-bash.cmd
Aling33 dede3faed4
fix(scripts): find Git Bash under a PortableGit mingw64 layout (#7214)
* fix(scripts): find Git Bash under a PortableGit mingw64 layout

`scripts/run-with-git-bash.cmd` derives `bash.exe` from `git.exe`'s parent,
which only holds for the Git for Windows `<root>/cmd` and `<root>/bin`
layouts. PortableGit and GitHub Desktop ship `git.exe` in
`<root>/mingw64/bin`, so the wrapper looked for `<root>/mingw64/bin/bash.exe`
and reported "Could not locate Git for Windows Bash" even though
`<root>/bin/bash.exe` exists. Every Makefile recipe that runs a repository
shell script failed on those hosts.

Resolve the shell under the Git installation root instead, and mirror the rule
in `backend/tests/support/shell.py` (documented as mirroring the wrapper) so
the shell-script suites stop skipping on the same hosts.

* test(backend): pin both Git layouts in one shell-discovery suite

Review follow-up for the PortableGit probe:

- `_git_roots` now probes `git.exe`'s parent and grandparent unconditionally —
  exactly the two directories the Makefile wrapper checks — so the batch probe
  and the Python mirror cannot drift; the docstring records that the first
  `mingw64` candidate normally misses and is kept only to mirror it.
- fold the candidate-layout cases and the Windows-only wrapper case into
  `tests/test_support_shell.py`, which already owns this module's unit tests,
  instead of a second file with a duplicate `_touch` helper.
- report the wrapper's stdout in the failure message: its diagnostic goes to
  stdout, so `stderr` was empty on the discovery-failure path.
2026-10-21 22:39:00 +08:00

24 lines
615 B
Batchfile

@echo off
setlocal
set "bash_exe="
for /f "delims=" %%I in ('where git 2^>NUL') do (
if exist "%%~dpI..\bin\bash.exe" (
set "bash_exe=%%~dpI..\bin\bash.exe"
goto :found_bash
)
if exist "%%~dpI..\..\bin\bash.exe" (
set "bash_exe=%%~dpI..\..\bin\bash.exe"
goto :found_bash
)
)
echo Could not locate Git for Windows Bash ("bin\bash.exe" under the git root). Ensure Git for Windows is installed and that git and bash.exe are available on PATH.
exit /b 1
:found_bash
echo Detected Windows - using Git Bash...
"%bash_exe%" %*
set "cmd_rc=%ERRORLEVEL%"
exit /b %cmd_rc%