refactor(dev-infra): migrate github api in GitClient to rely on GithubClient (#37593)

GitClient now uses GithubClient for github API interactions.  GithubClient is
a class which extends Octokit and provides a member which allows for GraphQL
requests against the Github GraphQL api, as well as providing convenience methods
for common/repeated Github API requests.

PR Close #37593
This commit is contained in:
Joey Perrott
2020-06-15 09:20:05 -07:00
committed by Misko Hevery
parent 7e0eccc4ef
commit a8af8551ec
8 changed files with 127 additions and 27 deletions

View File

@ -67,7 +67,7 @@ export async function loadAndValidatePullRequest(
}
const {data: {state}} =
await git.api.repos.getCombinedStatusForRef({...git.remoteParams, ref: prData.head.sha});
await git.github.repos.getCombinedStatusForRef({...git.remoteParams, ref: prData.head.sha});
if (state === 'failure' && !ignoreNonFatalFailures) {
return PullRequestFailure.failingCiJobs();
@ -102,7 +102,7 @@ export async function loadAndValidatePullRequest(
async function fetchPullRequestFromGithub(
git: GitClient, prNumber: number): Promise<Octokit.PullsGetResponse|null> {
try {
const result = await git.api.pulls.get({...git.remoteParams, pull_number: prNumber});
const result = await git.github.pulls.get({...git.remoteParams, pull_number: prNumber});
return result.data;
} catch (e) {
// If the pull request could not be found, we want to return `null` so