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

Function rig

evals/src/review-loop.test.ts:17–50  ·  view source on GitHub ↗
(scenario: Scenario = "review-loop")

Source from the content-addressed store, hash-verified

15const prUrl = "https://github.com/sandbox/run/pull/1";
16
17function rig(scenario: Scenario = "review-loop") {
18 let head = "initial";
19 let greeting: string = proposedGreeting;
20 const reviews: Array<{ id: number; state: string; commit_id: string; body: string }> = [];
21 const pull = () => ({
22 number: 1, html_url: prUrl, state: "open", merged: false, mergeable: true, merge_commit_sha: null,
23 head: { sha: head, ref: "improve-greeting" }, base: { ref: "main" },
24 });
25 const fixture: Fixture = { scenario, repo: "sandbox/run", workDir: "/unused", baseSha: "base", initialHead: head, pr: pull() };
26 const github = new EventsGitHub("test-only", async (input, init) => {
27 const url = new URL(String(input));
28 if (init?.method === "GET" && url.pathname === "/repos/sandbox/run/pulls/1") return Response.json(pull());
29 if (init?.method === "GET" && url.pathname === "/repos/sandbox/run/contents/greeting.txt") {
30 assert.equal(url.searchParams.get("ref"), head);
31 return Response.json({ encoding: "base64", content: Buffer.from(greeting).toString("base64") });
32 }
33 if (init?.method === "POST" && url.pathname === "/repos/sandbox/run/pulls/1/reviews") {
34 const body: Record<string, unknown> = JSON.parse(String(init.body));
35 assert.ok(typeof body.commit_id === "string" && typeof body.event === "string" && typeof body.body === "string");
36 const review = {
37 id: 100 + reviews.length, commit_id: body.commit_id, body: body.body,
38 state: body.event === "APPROVE" ? "APPROVED" : body.event === "COMMENT" ? "COMMENTED" : "CHANGES_REQUESTED",
39 };
40 reviews.push(review);
41 return Response.json(review);
42 }
43 throw new Error(`Unexpected request: ${init?.method} ${url}`);
44 });
45 return {
46 fixture, github, reviews, pull,
47 get greeting() { return greeting; },
48 push(sha: string, text: string) { head = sha; greeting = text; },
49 };
50}
51
52function wait(id: string, at: number): GhCall {
53 return {

Callers 2

completedLoopFunction · 0.85

Calls 3

pullFunction · 0.85
getMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected