test(runtime): keep inherited GIT_* env from aiming worktree-removal tests at an outer repo (#35853)

This commit is contained in:
Neil
2026-10-29 01:51:14 -07:00
committed by GitHub
parent a41fec9dd2
commit 6a03ed4990
@@ -201,6 +201,10 @@ async function failInSession(): Promise<unknown> {
describe.skipIf(process.platform !== 'darwin')('a worktree delete Git fails partway', () => {
beforeEach(async () => {
// A git hook's GIT_DIR/GIT_INDEX_FILE would point the scratch repo's git, and Orca's, at the outer repo.
for (const key of Object.keys(process.env).filter((name) => name.startsWith('GIT_'))) {
vi.stubEnv(key, undefined)
}
vi.spyOn(console, 'warn').mockImplementation(() => {})
scratchDir = await realpath(await mkdtemp(join(tmpdir(), 'orca-failed-removal-')))
recordsDir = join(scratchDir, 'profile')
@@ -228,6 +232,7 @@ describe.skipIf(process.platform !== 'darwin')('a worktree delete Git fails part
_resetPendingWorktreeRemovalsForTests()
vi.mocked(removeHostTree).mockClear()
vi.restoreAllMocks()
vi.unstubAllEnvs()
await setImmutable(false, scratchDir)
expect((await execFileAsync('find', [scratchDir, '-flags', '+uchg'])).stdout).toBe('')
await removeTree(scratchDir)