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

Function getStatusesForPullRequest

ng-dev/pr/common/fetch-pull-request.ts:221–267  ·  view source on GitHub ↗
(
  pullRequest: PullRequestFromGithub,
)

Source from the content-addressed store, hash-verified

219export async function fetchPullRequestFromGithub(
220 git: AuthenticatedGitClient,
221 prNumber: number,
222): Promise<PullRequestFromGithub | null> {
223 return await getPr(PR_SCHEMA, prNumber, git);
224}
225
226/** Fetches a pull request from Github. Returns null if an error occurred. */
227export async function fetchPendingPullRequestsFromGithub(
228 git: AuthenticatedGitClient,
229): Promise<PullRequestFromGithub[] | null> {
230 return await getPendingPrs(PR_SCHEMA, git);
231}
232
233/** Fetches a pull request from Github. Returns null if an error occurred. */
234export async function fetchPullRequestFilesFromGithub(
235 git: AuthenticatedGitClient,
236 prNumber: number,
237): Promise<PullRequestFilesFromGithub[] | null> {
238 return await getPrFiles(PR_FILES_SCHEMA, prNumber, git);
239}
240
241/** Fetches a pull request from Github. Returns null if an error occurred. */
242export async function fetchPullRequestCommentsFromGithub(
243 git: AuthenticatedGitClient,
244 prNumber: number,
245): Promise<PullRequestCommentsFromGithub[] | null> {
246 return await getPrComments(PR_COMMENTS_SCHEMA, prNumber, git);
247}
248
249/**
250 * Gets the statuses for a commit from a pull request, using a consistent interface
251 * for both status and checks results.
252 */
253export function getStatusesForPullRequest(
254 pullRequest: PullRequestFromGithub,
255): PullRequestStatusInfo {
256 const nodes = pullRequest.commits.nodes;
257 /** The combined github status and github checks object. */
258 const {statusCheckRollup} = nodes[nodes.length - 1].commit;
259
260 // If there is no status check rollup (i.e. no status nor checks), we
261 // consider the pull request status as failing.
262 if (!statusCheckRollup) {
263 return {
264 combinedStatus: PullRequestStatus.FAILING,
265 statuses: [],
266 };
267 }
268
269 /** A map of all of the statuses indexed by their names. */
270 const statusMap = new Map<string, PullRequestStatusInfo['statuses'][number]>();

Callers 3

assertMethod · 0.85
assertMethod · 0.85
assertMethod · 0.85

Calls 3

setMethod · 0.45

Tested by

no test coverage detected