( runtime: PRRuntime, ref: GhPRRef, )
| 801 | // --- PR List --- |
| 802 | |
| 803 | export async function fetchGhPRList( |
| 804 | runtime: PRRuntime, |
| 805 | ref: GhPRRef, |
| 806 | ): Promise<PRListItem[]> { |
| 807 | const result = await runtime.runCommand("gh", [ |
| 808 | "pr", "list", |
| 809 | "--repo", repoFlag(ref), |
| 810 | "--json", "number,title,author,url,baseRefName,state", |
| 811 | "--limit", "30", |
| 812 | "--state", "all", |
| 813 | ]); |
| 814 | |
| 815 | if (result.exitCode !== 0) return []; |
| 816 | |
| 817 | const raw = JSON.parse(result.stdout) as Array<{ |
| 818 | number: number; |
| 819 | title: string; |
| 820 | author: { login: string }; |
| 821 | url: string; |
| 822 | baseRefName: string; |
| 823 | state: string; |
| 824 | }>; |
| 825 | |
| 826 | return raw.map((pr) => ({ |
| 827 | id: String(pr.number), |
| 828 | number: pr.number, |
| 829 | title: pr.title, |
| 830 | author: pr.author.login, |
| 831 | url: pr.url, |
| 832 | baseBranch: pr.baseRefName, |
| 833 | state: (pr.state === "OPEN" ? "open" : pr.state === "MERGED" ? "merged" : "closed") as PRListItem["state"], |
| 834 | })); |
| 835 | } |
no test coverage detected