-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - bad commit message to ensure fixups are created for actual merging
- Loading branch information
1 parent
e520244
commit cf69b01
Showing
11 changed files
with
262 additions
and
271 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {params, types as graphqlTypes} from 'typed-graphqlify'; | ||
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client'; | ||
import {getPr} from '../../utils/github'; | ||
|
||
/** Graphql schema for the response body the requested pull request. */ | ||
/** Graphql schema for the response body the requested pull request. */ | ||
export const PR_SCHEMA = { | ||
url: graphqlTypes.string, | ||
isDraft: graphqlTypes.boolean, | ||
state: graphqlTypes.custom<PullRequestState>(), | ||
number: graphqlTypes.number, | ||
mergeable: graphqlTypes.custom<MergeableState>(), | ||
updatedAt: graphqlTypes.string, | ||
// Only the last 100 commits from a pull request are obtained as we likely will never see a pull | ||
// requests with more than 100 commits. | ||
commits: params( | ||
{last: 100}, | ||
{ | ||
totalCount: graphqlTypes.number, | ||
nodes: [ | ||
{ | ||
commit: { | ||
statusCheckRollup: { | ||
state: graphqlTypes.custom<StatusState>(), | ||
contexts: params( | ||
{last: 100}, | ||
{ | ||
nodes: [ | ||
onUnion({ | ||
CheckRun: { | ||
__typename: graphqlTypes.constant('CheckRun'), | ||
status: graphqlTypes.custom<CheckStatusState>(), | ||
conclusion: graphqlTypes.custom<CheckConclusionState>(), | ||
name: graphqlTypes.string, | ||
}, | ||
StatusContext: { | ||
__typename: graphqlTypes.constant('StatusContext'), | ||
state: graphqlTypes.custom<StatusState>(), | ||
context: graphqlTypes.string, | ||
}, | ||
}), | ||
], | ||
}, | ||
), | ||
}, | ||
message: graphqlTypes.string, | ||
}, | ||
}, | ||
], | ||
}, | ||
), | ||
maintainerCanModify: graphqlTypes.boolean, | ||
viewerDidAuthor: graphqlTypes.boolean, | ||
headRefOid: graphqlTypes.string, | ||
headRef: { | ||
name: graphqlTypes.string, | ||
repository: { | ||
url: graphqlTypes.string, | ||
nameWithOwner: graphqlTypes.string, | ||
}, | ||
}, | ||
baseRef: { | ||
name: graphqlTypes.string, | ||
repository: { | ||
url: graphqlTypes.string, | ||
nameWithOwner: graphqlTypes.string, | ||
}, | ||
}, | ||
baseRefName: graphqlTypes.string, | ||
title: graphqlTypes.string, | ||
labels: params( | ||
{first: 100}, | ||
{ | ||
nodes: [ | ||
{ | ||
name: graphqlTypes.string, | ||
}, | ||
], | ||
}, | ||
), | ||
}; | ||
|
||
/** A pull request retrieved from github via the graphql API. */ | ||
export type RawPullRequest = typeof PR_SCHEMA; | ||
|
||
/** Fetches a pull request from Github. Returns null if an error occurred. */ | ||
export async function fetchPullRequestFromGithub( | ||
git: AuthenticatedGitClient, | ||
prNumber: number, | ||
): Promise<RawPullRequest | null> { | ||
return await getPr(PR_SCHEMA, prNumber, git); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.