MCPcopy
hub / github.com/cursor/community-plugins / fetchGitHubTree

Function fetchGitHubTree

apps/cursor/src/lib/github-plugin/parse.ts:205–229  ·  view source on GitHub ↗
(
  owner: string,
  repo: string,
  opts: FetchOptions = {},
)

Source from the content-addressed store, hash-verified

203}
204
205async function fetchGitHubTree(
206 owner: string,
207 repo: string,
208 opts: FetchOptions = {},
209): Promise<{ path: string; type: string }[]> {
210 const url = `https://api.github.com/repos/${owner}/${repo}/git/trees/HEAD?recursive=1`;
211 try {
212 const res = await fetchWithRateLimit(url, {
213 cache: "no-store",
214 headers: {
215 Accept: "application/vnd.github.v3+json",
216 ...githubAuthHeaders(),
217 },
218 maxWaitMs: opts.maxWaitMs,
219 });
220 if (!res.ok) return [];
221 const data = await res.json();
222 return (data.tree ?? []).map((t: { path: string; type: string }) => ({
223 path: t.path,
224 type: t.type,
225 }));
226 } catch {
227 return [];
228 }
229}
230
231export type GitHubRepoMeta = {
232 id: number;

Callers 1

parseGitHubPluginFunction · 0.85

Calls 2

fetchWithRateLimitFunction · 0.85
githubAuthHeadersFunction · 0.85

Tested by

no test coverage detected