Skip to content

Commit 47e6117

Browse files
committed
Stop relying on Git for Windows being installed
This Action previously relied on Git for Windows to be installed in `C:\Program Files\Git`. That is true for all hosted Windows agents. However, this is not necessarily true for all self-hosted runners. But there usually _is_ a Git for Windows we can rely on: The build agent's own copy. Let's use that instead. This fixes #472 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent bf0a74b commit 47e6117

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/git.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ import {Octokit} from '@octokit/rest'
44
import {delimiter} from 'path'
55
import * as fs from 'fs'
66

7-
export const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
8-
const gitExePath = 'C:/Program Files/Git/cmd/git.exe'
7+
// If present, do prefer the build agent's copy of Git
8+
const externalsGitDir = `${process.env.AGENT_HOMEDIRECTORY}/externals/git`
9+
const gitForWindowsRoot = 'C:/Program Files/Git'
10+
const gitRoot = fs.existsSync(externalsGitDir)
11+
? externalsGitDir
12+
: gitForWindowsRoot
13+
14+
export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
15+
const gitExePath = `${gitRoot}/cmd/git.exe`
916

1017
/*
1118
* It looks a bit ridiculous to use 56 workers on a build agent that has only

0 commit comments

Comments
 (0)