MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / writeUploadPackRequest

Function writeUploadPackRequest

src/wire/writeUploadPackRequest.js:3–39  ·  view source on GitHub ↗
({
  capabilities = [],
  wants = [],
  haves = [],
  shallows = [],
  depth = null,
  since = null,
  exclude = [],
})

Source from the content-addressed store, hash-verified

1import { GitPktLine } from '../models/GitPktLine.js'
2
3export 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}

Callers 3

_fetchFunction · 0.90
test-wire.jsFile · 0.85

Calls 2

encodeMethod · 0.80
flushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…