(options: {
repo: RepoRef;
includeDrafts: boolean;
})
| 424 | } |
| 425 | |
| 426 | async function listOpenPullRequests(options: { |
| 427 | repo: RepoRef; |
| 428 | includeDrafts: boolean; |
| 429 | }): Promise<OpenPullRequestApiSummary[]> { |
| 430 | const perPage = 100; |
| 431 | const prs: OpenPullRequestApiSummary[] = []; |
| 432 | |
| 433 | for (let page = 1; ; page += 1) { |
| 434 | const url = new URL( |
| 435 | `https://api.github.com/repos/${options.repo.owner}/${options.repo.name}/pulls` |
| 436 | ); |
| 437 | url.searchParams.set('state', 'open'); |
| 438 | url.searchParams.set('per_page', String(perPage)); |
| 439 | url.searchParams.set('page', String(page)); |
| 440 | |
| 441 | const response = await githubRequest(url.toString()); |
| 442 | if (!response.ok) { |
| 443 | const bodyText = await response.text().catch(() => ''); |
| 444 | throw new Error( |
| 445 | `GitHub list pulls failed: ${response.status} ${response.statusText}${bodyText ? ` - ${bodyText}` : ''}` |
| 446 | ); |
| 447 | } |
| 448 | |
| 449 | const json = parseGithubListPullRequestsSummaryResponse(await response.json()); |
| 450 | if (options.includeDrafts) { |
| 451 | prs.push(...json); |
| 452 | } else { |
| 453 | prs.push(...json.filter(pr => !pr.draft)); |
| 454 | } |
| 455 | |
| 456 | if (json.length < perPage) { |
| 457 | return prs; |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | const ORG_MEMBERS_SCHEMA = z.array( |
| 463 | z.object({ |
no test coverage detected