feat(dev-infra): create rebase-pr tool in ng-dev (#37055)

Creates a tool in ng-dev which rebases a PR automatically and pushes
the rebase commits back to the PR.  This is meant to be a replacement
to the local merge script currently in the repo and currently has
feature parity.

PR Close #37055
This commit is contained in:
Joey Perrott
2020-05-11 15:21:18 -07:00
committed by Kara Erickson
parent 5ac5ac1dec
commit 009f394237
6 changed files with 221 additions and 0 deletions

View File

@ -26,6 +26,25 @@ const graphql = unauthenticatedGraphql.defaults({
}
});
/** Get a PR from github */
export async function getPr<PrSchema>(
prSchema: PrSchema, number: number, {owner, name}: GithubConfig) {
const PR_QUERY = params(
{
$number: 'Int!', // The PR number
$owner: 'String!', // The organization to query for
$name: 'String!', // The organization to query for
},
{
repository: params({owner: '$owner', name: '$name'}, {
pullRequest: params({number: '$number'}, prSchema),
})
});
const result = await graphql(graphqlQuery(PR_QUERY), {number, owner, name}) as typeof PR_QUERY;
return result.repository.pullRequest;
}
/** Get all pending PRs from github */
export async function getPendingPrs<PrSchema>(prSchema: PrSchema, {owner, name}: GithubConfig) {
// The GraphQL query object to get a page of pending PRs