feat(dev-infra): provide github API instance to lazy merge configuration (#38223)
The merge script currently accepts a configuration function that will be invoked _only_ when the `ng-dev merge` command is executed. This has been done that way because the merge tooling usually relies on external requests to Git or NPM for constructing the branch configurations. We do not want to perform these slow external queries on any `ng-dev` command though, so this became a lazily invoked function. This commit adds support for these configuration functions to run asynchronously (by returning a Promise that will be awaited), so that requests could also be made to the Github API. This is benefical as it could avoid dependence on the local Git state and the HTTP requests are more powerful/faster. Additionally, in order to be able to perform Github API requests with an authenticated instance, the merge tool will pass through a `GithubClient` instance that uses the specified `--github-token` (or from the environment). This ensures that all API requests use the same `GithubClient` instance and can be authenticated (mitigating potential rate limits). PR Close #38223
This commit is contained in:

committed by
Andrew Kushnir

parent
629203f17a
commit
84661eac64
@ -9,7 +9,7 @@
|
||||
import {promptConfirm} from '../../utils/console';
|
||||
import {GitClient, GitCommandError} from '../../utils/git';
|
||||
|
||||
import {MergeConfigWithRemote} from './config';
|
||||
import {MergeConfig, MergeConfigWithRemote} from './config';
|
||||
import {PullRequestFailure} from './failures';
|
||||
import {getCaretakerNotePromptMessage} from './messages';
|
||||
import {isPullRequest, loadAndValidatePullRequest,} from './pull-request';
|
||||
@ -43,12 +43,7 @@ export interface MergeResult {
|
||||
* labels that have been resolved through the merge script configuration.
|
||||
*/
|
||||
export class PullRequestMergeTask {
|
||||
/** Git client that can be used to execute Git commands. */
|
||||
git = new GitClient(this._githubToken, {github: this.config.remote});
|
||||
|
||||
constructor(
|
||||
public projectRoot: string, public config: MergeConfigWithRemote,
|
||||
private _githubToken: string) {}
|
||||
constructor(public config: MergeConfigWithRemote, public git: GitClient) {}
|
||||
|
||||
/**
|
||||
* Merges the given pull request and pushes it upstream.
|
||||
|
Reference in New Issue
Block a user