MCPcopy Create free account
hub / github.com/Tencent/teamai-cli / gitcodeCreateRepo

Function gitcodeCreateRepo

src/providers/gitcode/gitcode-api.ts:206–227  ·  view source on GitHub ↗
(owner: string, repo: string)

Source from the content-addressed store, hash-verified

204 * under an organization (`POST /orgs/{org}/repos`).
205 */
206export async function gitcodeCreateRepo(owner: string, repo: string): Promise<void> {
207 const token = requireToken();
208 const login = await gitcodeWhoami();
209
210 const isOrg = !login || login.toLowerCase() !== owner.toLowerCase();
211 const endpoint = isOrg
212 ? `${gitcodeApiBase()}/orgs/${encodeURIComponent(owner)}/repos`
213 : `${gitcodeApiBase()}/user/repos`;
214
215 const body: Record<string, unknown> = { name: repo, private: true, auto_init: true };
216
217 const resp = await fetch(endpoint, {
218 method: 'POST',
219 headers: authHeaders(token),
220 body: JSON.stringify(body),
221 redirect: 'manual',
222 });
223 if (!resp.ok) {
224 const errBody = await resp.text().catch(() => '');
225 throw new Error(`Failed to create GitCode repo: ${resp.status} ${errBody}`);
226 }
227}
228
229// ─── Pull requests ───────────────────────────────────────
230

Callers 1

createRepoMethod · 0.85

Calls 4

gitcodeWhoamiFunction · 0.85
gitcodeApiBaseFunction · 0.85
requireTokenFunction · 0.70
authHeadersFunction · 0.70

Tested by

no test coverage detected