({ capabilities, refs, symrefs })
| 2 | import { pkg } from '../utils/pkg.js' |
| 3 | |
| 4 | export async function writeRefsAdResponse({ capabilities, refs, symrefs }) { |
| 5 | const stream = [] |
| 6 | // Compose capabilities string |
| 7 | let syms = '' |
| 8 | for (const [key, value] of Object.entries(symrefs)) { |
| 9 | syms += `symref=${key}:${value} ` |
| 10 | } |
| 11 | let caps = `\x00${[...capabilities].join(' ')} ${syms}agent=${pkg.agent}` |
| 12 | // stream.write(GitPktLine.encode(`# service=${service}\n`)) |
| 13 | // stream.write(GitPktLine.flush()) |
| 14 | // Note: In the edge case of a brand new repo, zero refs (and zero capabilities) |
| 15 | // are returned. |
| 16 | for (const [key, value] of Object.entries(refs)) { |
| 17 | stream.push(GitPktLine.encode(`${value} ${key}${caps}\n`)) |
| 18 | caps = '' |
| 19 | } |
| 20 | stream.push(GitPktLine.flush()) |
| 21 | return stream |
| 22 | } |
no test coverage detected
searching dependent graphs…