MCPcopy Create free account
hub / github.com/anthropics/claude-code / githubRequest

Function githubRequest

scripts/auto-close-duplicates.ts:28–47  ·  view source on GitHub ↗
(endpoint: string, token: string, method: string = 'GET', body?: any)

Source from the content-addressed store, hash-verified

26}
27
28async function githubRequest<T>(endpoint: string, token: string, method: string = 'GET', body?: any): Promise<T> {
29 const response = await fetch(`https://api.github.com${endpoint}`, {
30 method,
31 headers: {
32 Authorization: `Bearer ${token}`,
33 Accept: "application/vnd.github.v3+json",
34 "User-Agent": "auto-close-duplicates-script",
35 ...(body && { "Content-Type": "application/json" }),
36 },
37 ...(body && { body: JSON.stringify(body) }),
38 });
39
40 if (!response.ok) {
41 throw new Error(
42 `GitHub API request failed: ${response.status} ${response.statusText}`
43 );
44 }
45
46 return response.json();
47}
48
49function extractDuplicateIssueNumber(commentBody: string): number | null {
50 // Try to match #123 format first

Callers 2

closeIssueAsDuplicateFunction · 0.70
autoCloseDuplicatesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected