| 1 | import { spawn } from 'node:child_process'; |
| 2 | import { PassThrough, type |
| 3 | |
| 4 | import { |
| 5 | type GitServiceName, |
| 6 | protocolEnv, |
| 7 | toGitBinary, |
| 8 | } from './git-service.js'; |
| 9 | |
| 10 | /** Runs upload-pack or receive-pack in `--stateless-rpc` mode and hands back its stdout, warning with whatever it writes to stderr. */ |
| 11 | export function spawnPack({ |
| 12 | service, |
| 13 | repoDirectory, |
| 14 | protocol, |
| 15 | flags = [], |
| 16 | input, |
| 17 | warn, |
| 18 | }: { |
| 19 | service: GitServiceName |
| 20 | repoDirectory: string |
| 21 | protocol?: string |
| 22 | flags?: string |
| 23 | input?: Readable |
| 24 | warn: (message |
| 25 | }): Readable { |
| 26 | const binary = |
| 27 | const output = |
| 28 | const child = |
| 29 | 'git', |
| 30 | [binary, '--stateless-rpc' |
| 31 | { env: { ... |
| 32 | ); |
| 33 | |
| 34 | if (input) input |
| 35 | else child.stdin. |
| 36 | child.stdout.pipe |
| 37 | child.stderr.on |
| 38 | warn(`${binary} |
| 39 | ); |
| 40 | child.on('error |
| 41 | |
| 42 | return output; |
| 43 | } |