()
| 287 | */ |
| 288 | async checkCaretakerNoteConfirmation(pullRequest: PullRequest): Promise<void> { |
| 289 | if (!pullRequest.hasCaretakerNote) { |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | const caretakerNote = await this.getCaretakerNote(pullRequest); |
| 294 | pullRequest.caretakerNote = caretakerNote; |
| 295 | |
| 296 | if ( |
| 297 | !(await Prompt.confirm({ |
| 298 | message: getCaretakerNotePromptMessage(pullRequest, caretakerNote), |
| 299 | })) |
| 300 | ) { |
| 301 | throw new UserAbortedMergeToolError(); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Searches the comments on the pull request for a single caretaker note. |
| 307 | * Returns the matching comment if exactly one is found, or undefined if |
| 308 | * none or multiple are found or if fetching fails. |
| 309 | */ |
| 310 | async getCaretakerNote(pullRequest: PullRequest): Promise<string | undefined> { |
| 311 | try { |
| 312 | const comments = await fetchPullRequestCommentsFromGithub(this.git, pullRequest.prNumber); |
| 313 | if (comments !== null) { |
| 314 | return getCaretakerNoteFromComments(comments) ?? undefined; |
| 315 | } |
| 316 | } catch (e) { |
| 317 | Log.debug(`Failed to fetch pull request comments for caretaker note: ${e}`); |
| 318 | } |
| 319 | return undefined; |
| 320 | } |
| 321 | |
| 322 | async confirmMergeAccess() { |
| 323 | if (this.git.userType === 'user') { |
| 324 | // Check whether the given Github token has sufficient permissions for writing |
no test coverage detected