MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / fetchGitlabArchive

Function fetchGitlabArchive

website/api/gitlab-zip.ts:24–61  ·  view source on GitHub ↗
(project: string, branch: string, token?: string)

Source from the content-addressed store, hash-verified

22}
23
24function fetchGitlabArchive(project: string, branch: string, token?: string): Promise<{
25 statusCode: number;
26 headers: Record<string, string | string[] | undefined>;
27 body: Buffer;
28}> {
29 const gitlabPath = `/api/v4/projects/${encodeURIComponent(project)}/repository/archive.zip?sha=${encodeURIComponent(branch)}`;
30 const headers: Record<string, string> = {
31 "User-Agent": "CodeGraphContext-Website/1.0",
32 Accept: "application/zip, application/octet-stream, */*",
33 };
34 if (token) {
35 headers["PRIVATE-TOKEN"] = token;
36 }
37
38 return new Promise((resolve, reject) => {
39 const req = https.request(
40 {
41 hostname: "gitlab.com",
42 path: gitlabPath,
43 method: "GET",
44 headers,
45 },
46 (res) => {
47 const chunks: Buffer[] = [];
48 res.on("data", (chunk) => chunks.push(chunk));
49 res.on("end", () => {
50 resolve({
51 statusCode: res.statusCode || 500,
52 headers: res.headers,
53 body: Buffer.concat(chunks),
54 });
55 });
56 }
57 );
58 req.on("error", reject);
59 req.end();
60 });
61}
62
63export default async function handler(req: any, res: any) {
64 if (req.method !== "GET" && req.method !== "HEAD") {

Callers 1

handlerFunction · 0.85

Calls 4

resolveFunction · 0.85
requestMethod · 0.80
onMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected