Skip to content

Commit 1b5d636

Browse files
committed
git.exe: add /cmd folder to PATH when calling bash.exe
1 parent 27d4979 commit 1b5d636

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

.jest/setEnvVars.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
This ensures that the PATH of the machine that the tests are running on,
3+
doesn't leak into our tests.
4+
*/
5+
process.env.PATH = ''

dist/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.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.

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
clearMocks: true,
33
moduleFileExtensions: ['js', 'ts'],
4+
setupFiles: ["<rootDir>/.jest/setEnvVars.ts"],
45
testEnvironment: 'node',
56
testMatch: ['**/*.test.ts'],
67
testRunner: 'jest-circus/runner',

src/__tests__/git.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ describe('git', () => {
4848
`--architecture=${architecture}`,
4949
`--out=${outputDirectory}`
5050
]),
51-
expect.any(Object)
51+
expect.objectContaining({
52+
env: expect.objectContaining({
53+
// We want to ensure that the /cmd folder is in the PATH,
54+
// so that please.sh can find git.exe
55+
PATH: expect.stringContaining('/cmd')
56+
})
57+
})
5258
)
5359
})
5460

src/git.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const gitRoot = fs.existsSync(externalsGitDir)
1212
: gitForWindowsRoot
1313

1414
export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
15-
const gitExePath = `${gitRoot}/cmd/git.exe`
15+
const gitCmdPath = `${gitRoot}/cmd`
16+
const gitExePath = `${gitCmdPath}/git.exe`
1617

1718
/*
1819
* It looks a bit ridiculous to use 56 workers on a build agent that has only
@@ -204,7 +205,7 @@ export async function getViaGit(
204205
LC_CTYPE: 'C.UTF-8',
205206
CHERE_INVOKING: '1',
206207
MSYSTEM: 'MINGW64',
207-
PATH: `${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}`
208+
PATH: `${gitCmdPath}${delimiter}${gitForWindowsUsrBinPath}${delimiter}${process.env.PATH}`
208209
},
209210
stdio: [undefined, 'inherit', 'inherit']
210211
}

0 commit comments

Comments
 (0)