MCPcopy
hub / github.com/iterative/cml / isProtected

Method isProtected

src/drivers/github.js:458–478  ·  view source on GitHub ↗

* @param {{ branch: string }} opts * @returns {Promise }

({ branch })

Source from the content-addressed store, hash-verified

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

Callers 1

prAutoMergeMethod · 0.95

Calls 2

ownerRepoMethod · 0.95
octokitFunction · 0.85

Tested by

no test coverage detected