MCPcopy Create free account
hub / github.com/cli/cli / once

Method once

evals/src/core/github.ts:85–107  ·  view source on GitHub ↗
(method: string, path: string, body?: unknown)

Source from the content-addressed store, hash-verified

83 }
84
85 private async once<T>(method: string, path: string, body?: unknown): Promise<{ body: T; next?: string }> {
86 const response = await this.request(`https://api.github.com${path}`, {
87 method,
88 redirect: "error",
89 signal: AbortSignal.timeout(30_000),
90 headers: {
91 Authorization: `Bearer ${this.token}`,
92 Accept: "application/vnd.github+json",
93 "Content-Type": "application/json",
94 "User-Agent": "gh-evals",
95 },
96 ...(body === undefined ? {} : { body: JSON.stringify(body) }),
97 });
98 const text = await response.text();
99 if (!response.ok) {
100 const retryAfterHeader = response.headers.get("retry-after");
101 const retryAfter = retryAfterHeader === null ? Number.NaN : Number(retryAfterHeader);
102 throw new ApiError(response.status, method, path, text || response.statusText,
103 Number.isFinite(retryAfter) && retryAfter >= 0 ? retryAfter * 1000 : undefined);
104 }
105 const next = /<https:\/\/api\.github\.com(\/[^>]*)>;\s*rel="next"/.exec(response.headers.get("link") ?? "")?.[1];
106 return { body: (text ? JSON.parse(text) : undefined) as T, ...(next ? { next } : {}) };
107 }
108
109 pull(repo: string, number: number): Promise<PullRequest> {
110 return this.api("GET", `/repos/${repo}/pulls/${number}`);

Callers 4

harness.test.tsFile · 0.80
waitForExitFunction · 0.80
mainFunction · 0.80
listenMethod · 0.80

Calls 2

requestMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected