MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / checkRefs

Function checkRefs

packages/plugins/apps/src/git-client/transport.ts:84–116  ·  view source on GitHub ↗
(
  url: string,
  auth: AuthRecipe = {},
  fetchImpl: typeof fetch = fetch,
  policy: GitUrlPolicy = {},
)

Source from the content-addressed store, hash-verified

82
83// The cheap "did it change" check: GET info/refs. Returns the ref advertisement.
84export async function checkRefs(
85 url: string,
86 auth: AuthRecipe = {},
87 fetchImpl: typeof fetch = fetch,
88 policy: GitUrlPolicy = {},
89): Promise<RefsResult> {
90 const repo = normalizeRepoUrl(url);
91 const infoUrl = `${repo}/info/refs?service=git-upload-pack`;
92 const t0 = Date.now();
93 const res = await fetchGit(
94 infoUrl,
95 {
96 headers: {
97 ...baseHeaders(auth),
98 accept: "*/*",
99 },
100 },
101 fetchImpl,
102 policy,
103 );
104 const buf = new Uint8Array(await res.arrayBuffer());
105 const wallMs = Date.now() - t0;
106 if (!res.ok) {
107 throw new Error(`info/refs ${res.status}: ${new TextDecoder().decode(buf.subarray(0, 200))}`);
108 }
109 const ct = res.headers.get("content-type") || "";
110 if (!ct.includes("git-upload-pack-advertisement")) {
111 // Some hosts (or a wrong URL) return HTML; treat as protocol failure.
112 throw new Error(`unexpected content-type: ${ct}`);
113 }
114 const adv = parseInfoRefs(buf);
115 return { adv, status: res.status, wallMs, bytes: buf.length };
116}
117
118export interface UploadPackOptions {
119 auth?: AuthRecipe;

Callers 3

app-source.test.tsFile · 0.90
handFetchFunction · 0.90
handRefsCheckFunction · 0.90

Calls 6

parseInfoRefsFunction · 0.90
normalizeRepoUrlFunction · 0.85
fetchGitFunction · 0.85
baseHeadersFunction · 0.85
arrayBufferMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected