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:

committed by
Kara Erickson

parent
5ac5ac1dec
commit
009f394237
35
dev-infra/pr/rebase/cli.ts
Normal file
35
dev-infra/pr/rebase/cli.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @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 {Arguments, Argv} from 'yargs';
|
||||
|
||||
import {rebasePr} from './index';
|
||||
|
||||
/** URL to the Github page where personal access tokens can be generated. */
|
||||
export const GITHUB_TOKEN_GENERATE_URL = `https://github.com/settings/tokens`;
|
||||
|
||||
/** Builds the rebase pull request command. */
|
||||
export function buildRebaseCommand(yargs: Argv) {
|
||||
return yargs.option('github-token', {
|
||||
type: 'string',
|
||||
description: 'Github token. If not set, token is retrieved from the environment variables.'
|
||||
});
|
||||
}
|
||||
|
||||
/** Handles the rebase pull request command. */
|
||||
export async function handleRebaseCommand(args: Arguments) {
|
||||
const githubToken = args.githubToken || process.env.GITHUB_TOKEN || process.env.TOKEN;
|
||||
if (!githubToken) {
|
||||
console.error('No Github token set. Please set the `GITHUB_TOKEN` environment variable.');
|
||||
console.error('Alternatively, pass the `--github-token` command line flag.');
|
||||
console.error(`You can generate a token here: ${GITHUB_TOKEN_GENERATE_URL}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await rebasePr(args.prNumber, githubToken);
|
||||
}
|
Reference in New Issue
Block a user