Files
hermes-agent/apps/desktop/electron/bootstrap-runner-git-binary.test.ts
teknium1 35a3f03571 fix(desktop): pin the bootstrap marker with the probed git, not the first PATH hit
resolveCheckoutHead ran a bare `git`, which resolves by PATH order and
so hits the same existing-but-unlaunchable Intel git the update check
now skips; execFileSync threw, was swallowed to null, and the
bootstrap-complete marker fell back to whatever pin was already on disk.

runBootstrap accepts `gitBinary` and threads it to resolveCheckoutHead;
main.ts passes resolveGitBinary(), so both paths use the same binary.
2026-09-18 09:37:29 -07:00

22 lines
921 B
TypeScript

import assert from 'node:assert/strict'
import type * as ChildProcess from 'node:child_process'
import { test, vi } from 'vitest'
const execFileSyncMock = vi.fn((..._args: unknown[]) => 'abcdef1234567890\n')
vi.mock('node:child_process', async importOriginal => ({
...(await importOriginal<typeof ChildProcess>()),
execFileSync: execFileSyncMock
}))
test('resolveCheckoutHead runs the probed git binary, not the first PATH hit (#114718)', async () => {
// The bootstrap marker pin used a bare `git`, which on the reported Mac is
// an Intel-only /usr/local/bin/git that fails at spawn, silently dropping
// the real pin. main.ts now passes the binary it already probed.
const { resolveCheckoutHead } = await import('./bootstrap-runner')
assert.equal(resolveCheckoutHead('/repo', { gitBinary: '/usr/bin/git' }), 'abcdef1234567890')
assert.equal(execFileSyncMock.mock.calls[0]?.[0], '/usr/bin/git')
})