fix(cli): discover Git Bash via PATH walk for non-default installs
WINDOWS_BASH_CANDIDATES only checks C:\Program Files{,(x86)}\Git, so
users who installed Git for Windows on a different drive (e.g.
D:\Program Files\Git\) hit "Cannot run repo scripts on Windows
without bash" even though Git Bash is available. AO_BASH_PATH is the
documented escape hatch but should not be required.
Add a PATH-walk fallback that finds bash.exe wherever Git's bin dir
sits — Git for Windows adds itself to PATH at install time, so this
covers the typical non-default-drive case without a subprocess or
registry lookup.
Reported by greptile review on PR #1025.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8dde130a0b
commit
efd0d408e1
|
|
@ -99,11 +99,24 @@ const WINDOWS_BASH_CANDIDATES = [
|
|||
"C:\\Program Files\\Git\\usr\\bin\\bash.exe",
|
||||
];
|
||||
|
||||
// Walk PATH searching for bash.exe. Lets us discover Git Bash installs on
|
||||
// non-default drives (e.g. D:\Program Files\Git) that the hardcoded list above
|
||||
// would miss. Returns the first match or null. PATH-walking is sync but
|
||||
// microseconds — no subprocess.
|
||||
function findBashOnPath(): string | null {
|
||||
const dirs = (process.env["PATH"] ?? "").split(";").filter(Boolean);
|
||||
for (const dir of dirs) {
|
||||
const candidate = resolve(dir, "bash.exe");
|
||||
if (existsSync(candidate)) return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function detectWindowsBash(): string | null {
|
||||
for (const candidate of WINDOWS_BASH_CANDIDATES) {
|
||||
if (existsSync(candidate)) return candidate;
|
||||
}
|
||||
return null;
|
||||
return findBashOnPath();
|
||||
}
|
||||
|
||||
export function hasRepoScript(scriptName: string): boolean {
|
||||
|
|
|
|||
Loading…
Reference in New Issue