(stream)
| 9 | */ |
| 10 | |
| 11 | export async function parseListRefsResponse(stream) { |
| 12 | const read = GitPktLine.streamReader(stream) |
| 13 | |
| 14 | // TODO: when we re-write everything to minimize memory usage, |
| 15 | // we could make this a generator |
| 16 | const refs = [] |
| 17 | |
| 18 | let line |
| 19 | while (true) { |
| 20 | line = await read() |
| 21 | if (line === true) break |
| 22 | if (line === null) continue |
| 23 | line = line.toString('utf8').replace(/\n$/, '') |
| 24 | const [oid, ref, ...attrs] = line.split(' ') |
| 25 | const r = { ref, oid } |
| 26 | for (const attr of attrs) { |
| 27 | const [name, value] = attr.split(':') |
| 28 | if (name === 'symref-target') { |
| 29 | r.target = value |
| 30 | } else if (name === 'peeled') { |
| 31 | r.peeled = value |
| 32 | } |
| 33 | } |
| 34 | refs.push(r) |
| 35 | } |
| 36 | |
| 37 | return refs |
| 38 | } |
no test coverage detected
searching dependent graphs…