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

Function createSandbox

evals/src/core/sandbox.ts:57–82  ·  view source on GitHub ↗
(
  github: GitHub, org: string, suite: string, journalPath: string,
)

Source from the content-addressed store, hash-verified

55
56/** Creates an empty private sandbox repository in `org`, journaling it before and after creation. */
57export async function createSandbox(
58 github: GitHub, org: string, suite: string, journalPath: string,
59): Promise<{ repo: string; journal: Journal }> {
60 const repo = `${org}/run-${randomUUID()}`;
61 const journal: Journal = { version: 2, suite, repo, cleaned: false, resources: {} };
62 await save(journalPath, journal);
63 let created: { id: number; full_name: string; private: boolean };
64 try {
65 created = await github.api("POST", `/orgs/${org}/repos`, {
66 name: repo.split("/")[1], private: true, has_issues: false, has_wiki: false,
67 allow_merge_commit: true, auto_init: false,
68 });
69 } catch (error) {
70 if (error instanceof ApiError && error.status >= 400 && error.status < 500) {
71 journal.cleaned = true;
72 await save(journalPath, journal);
73 }
74 throw error;
75 }
76 journal.id = created.id;
77 await save(journalPath, journal);
78 if (created.full_name.toLowerCase() !== repo.toLowerCase() || !created.private) {
79 throw new Error("GitHub created an unexpected repository");
80 }
81 return { repo, journal };
82}
83
84/**
85 * Deletes the sandbox repository after confirming its identity and privacy. `beforeDelete` removes the suite's other

Callers 1

provisionFunction · 0.85

Calls 2

saveFunction · 0.85
apiMethod · 0.80

Tested by

no test coverage detected