| 23 | * @see PackObjectsResult |
| 24 | */ |
| 25 | export async function _packObjects({ fs, cache, gitdir, oids, write }) { |
| 26 | const buffers = await _pack({ fs, cache, gitdir, oids }) |
| 27 | const packfile = Buffer.from(await collect(buffers)) |
| 28 | const packfileSha = packfile.slice(-20).toString('hex') |
| 29 | const filename = `pack-${packfileSha}.pack` |
| 30 | if (write) { |
| 31 | await fs.write(join(gitdir, `objects/pack/${filename}`), packfile) |
| 32 | return { filename } |
| 33 | } |
| 34 | return { |
| 35 | filename, |
| 36 | packfile: new Uint8Array(packfile), |
| 37 | } |
| 38 | } |