MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / buildPushRequest

Function buildPushRequest

services/app-builder/src/git/git-clone-service.test.ts:12–41  ·  view source on GitHub ↗
(
  refs: Array<{ oldOid: string; newOid: string; refName: string }>,
  packfileBytes: Uint8Array
)

Source from the content-addressed store, hash-verified

10// ---------------------------------------------------------------------------
11
12function buildPushRequest(
13 refs: Array<{ oldOid: string; newOid: string; refName: string }>,
14 packfileBytes: Uint8Array
15): Uint8Array {
16 const encoder = new TextEncoder();
17 const chunks: Uint8Array[] = [];
18
19 for (let i = 0; i < refs.length; i++) {
20 const { oldOid, newOid, refName } = refs[i];
21 let line = `${oldOid} ${newOid} ${refName}`;
22 if (i === 0) {
23 line += '\0 report-status';
24 }
25 line += '\n';
26 const lengthHex = (line.length + 4).toString(16).padStart(4, '0');
27 chunks.push(encoder.encode(lengthHex + line));
28 }
29
30 chunks.push(encoder.encode('0000'));
31 chunks.push(packfileBytes);
32
33 const totalLength = chunks.reduce((sum, c) => sum + c.length, 0);
34 const result = new Uint8Array(totalLength);
35 let offset = 0;
36 for (const chunk of chunks) {
37 result.set(chunk, offset);
38 offset += chunk.length;
39 }
40 return result;
41}
42
43const zeroOid = '0'.repeat(40);
44

Callers 1

pushToRepoFunction · 0.70

Calls 3

pushMethod · 0.80
toStringMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected