({
capabilities = [],
wants = [],
haves = [],
shallows = [],
depth = null,
since = null,
exclude = [],
})
| 1 | import { GitPktLine } from '../models/GitPktLine.js' |
| 2 | |
| 3 | export function writeUploadPackRequest({ |
| 4 | capabilities = [], |
| 5 | wants = [], |
| 6 | haves = [], |
| 7 | shallows = [], |
| 8 | depth = null, |
| 9 | since = null, |
| 10 | exclude = [], |
| 11 | }) { |
| 12 | const packstream = [] |
| 13 | wants = [...new Set(wants)] // remove duplicates |
| 14 | let firstLineCapabilities = ` ${capabilities.join(' ')}` |
| 15 | for (const oid of wants) { |
| 16 | packstream.push(GitPktLine.encode(`want ${oid}${firstLineCapabilities}\n`)) |
| 17 | firstLineCapabilities = '' |
| 18 | } |
| 19 | for (const oid of shallows) { |
| 20 | packstream.push(GitPktLine.encode(`shallow ${oid}\n`)) |
| 21 | } |
| 22 | if (depth !== null) { |
| 23 | packstream.push(GitPktLine.encode(`deepen ${depth}\n`)) |
| 24 | } |
| 25 | if (since !== null) { |
| 26 | packstream.push( |
| 27 | GitPktLine.encode(`deepen-since ${Math.floor(since.valueOf() / 1000)}\n`) |
| 28 | ) |
| 29 | } |
| 30 | for (const oid of exclude) { |
| 31 | packstream.push(GitPktLine.encode(`deepen-not ${oid}\n`)) |
| 32 | } |
| 33 | packstream.push(GitPktLine.flush()) |
| 34 | for (const oid of haves) { |
| 35 | packstream.push(GitPktLine.encode(`have ${oid}\n`)) |
| 36 | } |
| 37 | packstream.push(GitPktLine.encode(`done\n`)) |
| 38 | return packstream |
| 39 | } |
no test coverage detected
searching dependent graphs…