feat(dev-infra): support for caretaker note label in merge script (#37595) (#37778)

Adds support for a caretaker note label to the merge script.
Whenever a configured label is applied, the merge script will
not merge automatically, but instead prompt first in order
to ensure that the caretaker paid attention to the manual
caretaker note on the PR. This helps if a PR needs special
attention.

PR Close #37595

PR Close #37778
This commit is contained in:
Paul Gschwendtner
2020-06-16 00:20:36 +02:00
committed by atscott
parent b76a2dc2cb
commit 489eb8519e
5 changed files with 41 additions and 2 deletions

View File

@ -6,10 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {promptConfirm} from '../../utils/console';
import {GitClient, GitCommandError} from '../../utils/git';
import {MergeConfigWithRemote} from './config';
import {PullRequestFailure} from './failures';
import {getCaretakerNotePromptMessage} from './messages';
import {isPullRequest, loadAndValidatePullRequest,} from './pull-request';
import {GithubApiMergeStrategy} from './strategies/api-merge';
import {AutosquashMergeStrategy} from './strategies/autosquash-merge';
@ -23,6 +25,7 @@ export const enum MergeStatus {
DIRTY_WORKING_DIR,
SUCCESS,
FAILED,
USER_ABORTED,
GITHUB_ERROR,
}
@ -72,6 +75,14 @@ export class PullRequestMergeTask {
return {status: MergeStatus.FAILED, failure: pullRequest};
}
// If the pull request has a caretaker note applied, raise awareness by prompting
// the caretaker. The caretaker can then decide to proceed or abort the merge.
if (pullRequest.hasCaretakerNote &&
!await promptConfirm(
getCaretakerNotePromptMessage(pullRequest) + `\nDo you want to proceed merging?`)) {
return {status: MergeStatus.USER_ABORTED};
}
const strategy = this.config.githubApiMerge ?
new GithubApiMergeStrategy(this.git, this.config.githubApiMerge) :
new AutosquashMergeStrategy(this.git);