diff --git a/dev-infra/pr/merge/messages.ts b/dev-infra/pr/merge/messages.ts index dbcb0aac66..34a34ce3db 100644 --- a/dev-infra/pr/merge/messages.ts +++ b/dev-infra/pr/merge/messages.ts @@ -11,5 +11,11 @@ import {PullRequest} from './pull-request'; export function getCaretakerNotePromptMessage(pullRequest: PullRequest): string { return red('Pull request has a caretaker note applied. Please make sure you read it.') + - `\nQuick link to PR: ${pullRequest.url}`; + `\nQuick link to PR: ${pullRequest.url}\nDo you want to proceed merging?`; +} + +export function getTargettedBranchesConfirmationPromptMessage(pullRequest: PullRequest): string { + const targetBranchListAsString = pullRequest.targetBranches.map(b => ` - ${b}\n`).join(''); + return `Pull request #${pullRequest.prNumber} will merge into:\n${ + targetBranchListAsString}\nDo you want to proceed merging?`; } diff --git a/dev-infra/pr/merge/task.ts b/dev-infra/pr/merge/task.ts index 4d20d2a338..42ca89898f 100644 --- a/dev-infra/pr/merge/task.ts +++ b/dev-infra/pr/merge/task.ts @@ -9,9 +9,9 @@ import {promptConfirm} from '../../utils/console'; import {GitClient, GitCommandError} from '../../utils/git'; -import {MergeConfig, MergeConfigWithRemote} from './config'; +import {MergeConfigWithRemote} from './config'; import {PullRequestFailure} from './failures'; -import {getCaretakerNotePromptMessage} from './messages'; +import {getCaretakerNotePromptMessage, getTargettedBranchesConfirmationPromptMessage} from './messages'; import {isPullRequest, loadAndValidatePullRequest,} from './pull-request'; import {GithubApiMergeStrategy} from './strategies/api-merge'; import {AutosquashMergeStrategy} from './strategies/autosquash-merge'; @@ -78,11 +78,16 @@ export class PullRequestMergeTask { return {status: MergeStatus.FAILED, failure: pullRequest}; } + + if (!await promptConfirm(getTargettedBranchesConfirmationPromptMessage(pullRequest))) { + return {status: MergeStatus.USER_ABORTED}; + } + + // 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?`)) { + !await promptConfirm(getCaretakerNotePromptMessage(pullRequest))) { return {status: MergeStatus.USER_ABORTED}; }