refactor(dev-infra): share more github code between commands (#38656)
Instead of repeating the logic for adding the github token to a repository git url, we add a shared function for automatically computing the URls with token. Additionally, URLs for updating/generating tokens have been moved to a dedicated file in the `utils` folder. Also while being at it, the yargs github token helper is also moved into the dedicated Git/Github related util folder. PR Close #38656
This commit is contained in:

committed by
Alex Rickabaugh

parent
4744c229db
commit
758d0e2045
@ -8,7 +8,7 @@
|
||||
|
||||
import {Arguments, Argv} from 'yargs';
|
||||
|
||||
import {addGithubTokenFlag} from '../../utils/yargs';
|
||||
import {addGithubTokenOption} from '../../utils/git/github-yargs';
|
||||
|
||||
import {mergePullRequest} from './index';
|
||||
|
||||
@ -20,7 +20,7 @@ export interface MergeCommandOptions {
|
||||
|
||||
/** Builds the options for the merge command. */
|
||||
export function buildMergeCommand(yargs: Argv): Argv<MergeCommandOptions> {
|
||||
return addGithubTokenFlag(yargs).help().strict().positional(
|
||||
return addGithubTokenOption(yargs).help().strict().positional(
|
||||
'pr-number', {demandOption: true, type: 'number'});
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,11 @@ import {getConfig, getRepoBaseDir} from '../../utils/config';
|
||||
import {error, green, info, promptConfirm, red, yellow} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GithubApiRequestError} from '../../utils/git/github';
|
||||
import {GITHUB_TOKEN_GENERATE_URL} from '../../utils/yargs';
|
||||
import {GITHUB_TOKEN_GENERATE_URL} from '../../utils/git/github-urls';
|
||||
|
||||
import {loadAndValidateConfig, MergeConfigWithRemote} from './config';
|
||||
import {MergeResult, MergeStatus, PullRequestMergeTask} from './task';
|
||||
|
||||
|
||||
/**
|
||||
* Merges a given pull request based on labels configured in the given merge configuration.
|
||||
* Pull requests can be merged with different strategies such as the Github API merge
|
||||
|
Reference in New Issue
Block a user