mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
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.
26 lines
931 B
TypeScript
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')
|
|
})
|