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

Function testRepoPermission

src/utils/github.ts:69–89  ·  view source on GitHub ↗
(
  token: string,
  owner: string,
  repo: string
)

Source from the content-addressed store, hash-verified

67}
68
69export async function testRepoPermission(
70 token: string,
71 owner: string,
72 repo: string
73): Promise<{ canCreate: boolean; error?: string }> {
74 const repoRes = await ghFetch(`/repos/${owner}/${repo}`, token);
75 if (!repoRes.ok) {
76 const err = await repoRes.json().catch(() => ({ message: repoRes.statusText }));
77 return { canCreate: false, error: `Cannot access repo: ${err.message}` };
78 }
79 const repoData = await repoRes.json();
80 if (repoData.permissions) {
81 if (!repoData.permissions.push && !repoData.permissions.admin) {
82 return {
83 canCreate: false,
84 error: "You don't have write (push) access to this repository.",
85 };
86 }
87 }
88 return { canCreate: true };
89}
90
91// ── Issue API ──
92

Callers 1

handleSelectRepoFunction · 0.90

Calls 1

ghFetchFunction · 0.85

Tested by

no test coverage detected