Files
orca/src/main/git/runner-buffer-stdin.test.ts
T
Neil b03ac56c00 fix(git): forward stdin on buffered Git reads (#30634)
gitExecFileAsyncBuffer never passed stdin to the child, so a buffered read
that needs it (cat-file --batch, hash-object --stdin) waited for EOF until
its timeout. Add the option and forward it, with a real-Git regression
test.
2026-10-19 14:18:03 -07:00

26 lines
931 B
TypeScript

import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, expect, it } from 'vitest'
import { gitExecFileAsync, gitExecFileAsyncBuffer } from './runner'
const roots: string[] = []
afterEach(async () => {
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })))
})
it('delivers stdin to buffered Git reads', async () => {
const repository = await mkdtemp(join(tmpdir(), 'orca-git-buffer-stdin-'))
roots.push(repository)
await gitExecFileAsync(['init', '--quiet'], { cwd: repository })
// Why a short timeout: a dropped stdin leaves Git waiting for EOF instead of failing.
const { stdout } = await gitExecFileAsyncBuffer(['hash-object', '--stdin'], {
cwd: repository,
stdin: 'hello\n',
timeout: 10_000
})
expect(stdout.toString().trim()).toBe('ce013625030ba8dba906f756967f9e9ca394464a')
})