Skip to content

Commit 873a0ce

Browse files
committed
fix: add script to find the git binaries on Windows
1 parent ae8148b commit 873a0ce

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/git/git.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { existsSync } from "fs"
2+
import { warning } from "ci-log"
13
import { addPath } from "envosman"
24
import { installAptPack } from "setup-apt"
35
import { installBrewPack } from "setup-brew"
@@ -14,8 +16,10 @@ export async function setupGit(version: string, _setupDir: string, _arch: string
1416
switch (process.platform) {
1517
case "win32": {
1618
const result = await setupChocoPack("git", version)
17-
result.binDir = "C:/Program Files (x86)/Git/bin"
18-
await addPath(result.binDir, rcOptions)
19+
const gitDir = findWindowsGit()
20+
if (gitDir !== null) {
21+
await addPath(gitDir, rcOptions)
22+
}
1923
return result
2024
}
2125
case "darwin": {
@@ -36,3 +40,18 @@ export async function setupGit(version: string, _setupDir: string, _arch: string
3640
}
3741
}
3842
}
43+
44+
function findWindowsGit() {
45+
const candidates = [
46+
"C:/Program Files/Git/bin/git.exe",
47+
"C:/Program Files (x86)/Git/bin/git.exe",
48+
]
49+
for (const candidate of candidates) {
50+
if (existsSync(candidate)) {
51+
return candidate
52+
}
53+
}
54+
55+
warning("Git not found in the default locations. Add git to PATH manually.")
56+
return null
57+
}

0 commit comments

Comments
 (0)