* @param {{ branch: string }} opts * @returns {Promise }
({ branch })
| 456 | * @returns {Promise<boolean>} |
| 457 | */ |
| 458 | async isProtected({ branch }) { |
| 459 | const octo = octokit(this.token, this.repo); |
| 460 | const { owner, repo } = this.ownerRepo(); |
| 461 | try { |
| 462 | await octo.repos.getBranchProtection({ |
| 463 | branch, |
| 464 | owner, |
| 465 | repo |
| 466 | }); |
| 467 | return true; |
| 468 | } catch (error) { |
| 469 | const errors = [ |
| 470 | 'Branch not protected', |
| 471 | 'Upgrade to GitHub Pro or make this repository public to enable this feature.' |
| 472 | ]; |
| 473 | if (errors.includes(error.message)) { |
| 474 | return false; |
| 475 | } |
| 476 | throw error; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * @param {{ pullRequestId: number, base: string }} param0 |
no test coverage detected