( runtime: PRRuntime, ref: GhPRRef, headSha: string, action: "approve" | "comment", body: string, fileComments: PRReviewFileComment[], )
| 643 | // --- Submit PR Review --- |
| 644 | |
| 645 | export 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 |
no test coverage detected