MCPcopy Create free account
hub / github.com/backnotprop/plannotator / submitGhPRReview

Function submitGhPRReview

packages/shared/pr-github.ts:645–678  ·  view source on GitHub ↗
(
  runtime: PRRuntime,
  ref: GhPRRef,
  headSha: string,
  action: "approve" | "comment",
  body: string,
  fileComments: PRReviewFileComment[],
)

Source from the content-addressed store, hash-verified

643// --- Submit PR Review ---
644
645export async function submitGhPRReview(
646 runtime: PRRuntime,
647 ref: GhPRRef,
648 headSha: string,
649 action: "approve" | "comment",
650 body: string,
651 fileComments: PRReviewFileComment[],
652): Promise<void> {
653 const payload = JSON.stringify({
654 commit_id: headSha,
655 body,
656 event: action === "approve" ? "APPROVE" : "COMMENT",
657 comments: fileComments,
658 });
659
660 const endpoint = `repos/${ref.owner}/${ref.repo}/pulls/${ref.number}/reviews`;
661
662 let result: CommandResult;
663
664 if (runtime.runCommandWithInput) {
665 result = await runtime.runCommandWithInput(
666 "gh",
667 hostnameArgs(ref.host, ["api", endpoint, "--method", "POST", "--input", "-"]),
668 payload,
669 );
670 } else {
671 throw new Error("Runtime does not support stdin input; cannot submit PR review");
672 }
673
674 if (result.exitCode !== 0) {
675 const message = result.stderr.trim() || result.stdout.trim() || `exit code ${result.exitCode}`;
676 throw new Error(`Failed to submit PR review: ${message}`);
677 }
678}
679
680// --- Stack Tree (GraphQL) ---
681

Callers 1

submitPRReviewFunction · 0.90

Calls 1

hostnameArgsFunction · 0.85

Tested by

no test coverage detected