MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / listOpenPullRequests

Function listOpenPullRequests

apps/web/src/lib/github/open-pull-request-counts.ts:426–460  ·  view source on GitHub ↗
(options: {
  repo: RepoRef;
  includeDrafts: boolean;
})

Source from the content-addressed store, hash-verified

424}
425
426async 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
462const ORG_MEMBERS_SCHEMA = z.array(
463 z.object({

Callers 1

Calls 7

pushMethod · 0.80
githubRequestFunction · 0.70
setMethod · 0.65
toStringMethod · 0.65
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected