(
owner: string,
repo: string,
opts: FetchOptions = {},
)
| 203 | } |
| 204 | |
| 205 | async 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 | |
| 231 | export type GitHubRepoMeta = { |
| 232 | id: number; |
no test coverage detected