Skip to content

Commit

Permalink
git.exe: add /cmd folder to PATH when calling bash.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Sep 10, 2024
1 parent 27d4979 commit 1b5d636
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .jest/setEnvVars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
This ensures that the PATH of the machine that the tests are running on,
doesn't leak into our tests.
*/
process.env.PATH = ''
5 changes: 3 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
setupFiles: ["<rootDir>/.jest/setEnvVars.ts"],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
Expand Down
8 changes: 7 additions & 1 deletion src/__tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ describe('git', () => {
`--architecture=${architecture}`,
`--out=${outputDirectory}`
]),
expect.any(Object)
expect.objectContaining({
env: expect.objectContaining({
// We want to ensure that the /cmd folder is in the PATH,
// so that please.sh can find git.exe
PATH: expect.stringContaining('/cmd')
})
})
)
})

Expand Down
5 changes: 3 additions & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const gitRoot = fs.existsSync(externalsGitDir)
: gitForWindowsRoot

export const gitForWindowsUsrBinPath = `${gitRoot}/usr/bin`
const gitExePath = `${gitRoot}/cmd/git.exe`
const gitCmdPath = `${gitRoot}/cmd`
const gitExePath = `${gitCmdPath}/git.exe`

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

0 comments on commit 1b5d636

Please sign in to comment.