Skip to content

Commit

Permalink
refactor project
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbokvad committed Oct 2, 2023
1 parent 61a83c6 commit 8703bbd
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@ export class BranchProtectionService {
repo,
branch: 'main',
});
console.log(response);
console.log(response.data);
// const octokit = github.getOctokit(token);
// const response = await octokit.rest.repos.getBranchProtection({
// owner,
// repo,
// branch: 'main',
// });
// if (response.data.enforce_admins?.enabled === false) {
// console.log('Branch protection can be overridden by admins and is therefore counted as not enabled');
// }
if (response.data.enforce_admins?.enabled === false) {
console.log('Branch protection can be overridden by admins and is therefore counted as not enabled');
}

// const numberOfReviewers: number =
// response.data.required_pull_request_reviews?.required_approving_review_count || 0;
const numberOfReviewers: number =
response.data.required_pull_request_reviews?.required_approving_review_count || 0;

// if (numberOfReviewers >= 1 && response.data.enforce_admins?.enabled === true) {
// console.log('Branch protection is enabled, number of reviewers:', numberOfReviewers);
// } else {
// console.log('Branch protection is not enabled for repository:', repo);
// }
if (numberOfReviewers >= 1 && response.data.enforce_admins?.enabled === true) {
console.log('Branch protection is enabled, number of reviewers:', numberOfReviewers);
} else {
console.log('Branch protection is not enabled for repository:', repo);
}

// core.exportVariable('numberOfReviewers', numberOfReviewers);
core.exportVariable('numberOfReviewers', numberOfReviewers);
} catch (error) {
console.log('Error:', error.message);
}
Expand Down

0 comments on commit 8703bbd

Please sign in to comment.