MCPcopy Create free account
hub / github.com/angular/dev-infra / getPendingPrs

Function getPendingPrs

ng-dev/utils/github.ts:54–108  ·  view source on GitHub ↗
(prSchema: PrSchema, git: AuthenticatedGitClient)

Source from the content-addressed store, hash-verified

52
53/** Get all pending PRs from github */
54export async function getPendingPrs<PrSchema>(prSchema: PrSchema, git: AuthenticatedGitClient) {
55 /** The owner and name of the repository */
56 const {owner, name} = git.remoteConfig;
57 /** The Graphql query object to get a page of pending PRs */
58 const PRS_QUERY = params(
59 {
60 $first: 'Int', // How many entries to get with each request
61 $after: 'String', // The cursor to start the page at
62 $owner: 'String!', // The organization to query for
63 $name: 'String!', // The repository to query for
64 },
65 {
66 repository: params(
67 {owner: '$owner', name: '$name'},
68 {
69 pullRequests: params(
70 {
71 first: '$first',
72 after: '$after',
73 states: `OPEN`,
74 },
75 {
76 nodes: [prSchema],
77 pageInfo: {
78 hasNextPage: types.boolean,
79 endCursor: types.string,
80 },
81 },
82 ),
83 },
84 ),
85 },
86 );
87 /** The current cursor */
88 let cursor: string | undefined;
89 /** If an additional page of members is expected */
90 let hasNextPage = true;
91 /** Array of pending PRs */
92 const prs: Array<PrSchema> = [];
93
94 // For each page of the response, get the page and add it to the list of PRs
95 while (hasNextPage) {
96 const paramsValue = {
97 after: cursor || null,
98 first: 100,
99 owner,
100 name,
101 };
102 const results = (await git.github.graphql(PRS_QUERY, paramsValue)) as typeof PRS_QUERY;
103 prs.push(...results.repository.pullRequests.nodes);
104 hasNextPage = results.repository.pullRequests.pageInfo.hasNextPage;
105 cursor = results.repository.pullRequests.pageInfo.endCursor;
106 }
107 return prs;
108}
109
110/** Get all files in a PR from github */
111export async function getPrFiles<PrFileSchema>(

Callers 1

Calls 2

graphqlMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected