MCPcopy Create free account
hub / github.com/SIMARSINGHRAYAT/Gitzo / ghFetch

Function ghFetch

src/utils/github.ts:8–24  ·  view source on GitHub ↗
(path: string, token: string, options?: RequestInit)

Source from the content-addressed store, hash-verified

6 * Wrapper around fetch that adds GitHub auth headers and handles network errors.
7 */
8export async function ghFetch(path: string, token: string, options?: RequestInit) {
9 try {
10 const res = await fetch(`https://api.github.com${path}`, {
11 ...options,
12 headers: {
13 Authorization: `token ${token}`,
14 Accept: 'application/vnd.github.v3+json',
15 'X-GitHub-Api-Version': API_VERSION,
16 ...(options?.headers || {}),
17 },
18 });
19 return res;
20 } catch (err) {
21 const message = err instanceof Error ? err.message : 'Network request failed';
22 throw new Error(`NETWORK_ERROR: ${message}`);
23 }
24}
25
26export function detectTokenType(token: string): TokenType {
27 if (token.startsWith('ghp_')) return 'classic';

Callers 15

validateTokenFunction · 0.85
fetchAllReposFunction · 0.85
testRepoPermissionFunction · 0.85
createIssueFunction · 0.85
closeIssueFunction · 0.85
getDefaultBranchSHAFunction · 0.85
createBranchFunction · 0.85
createFileOnBranchFunction · 0.85
createPullRequestFunction · 0.85
requestPRReviewFunction · 0.85
waitForMergeableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected