Skip to content

Commit

Permalink
refactor project
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbokvad committed Sep 28, 2023
1 parent d7d8659 commit 94f9056
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ export class BranchProtectionService {
public static async getStateOfBranchProtection(): Promise<void> {
console.log('\n Running branch protection control');

const octokit: Octokit = new Octokit();
// const octokit: Octokit = new Octokit();
const { owner, repo }: { owner: string; repo: string } = github.context.repo;
octokit.repos
.getBranchProtection({
owner: owner,
repo: repo,
branch: 'main',
})
.then((response: any) => {
console.log(
'Branch protection is enabled, and reviewers needed are:',
response.data.required_approving_review_count
);
console.log(response.data);
})
.catch((error: any) => {
console.log('Branch protections is not enabled for repository: ' + repo);
console.log('Error:', error?.message);
});
// octokit.repos
// .getBranchProtection({
// owner: owner,
// repo: repo,
// branch: 'main',
// })
// .then((response: any) => {
// console.log(
// 'Branch protection is enabled, and reviewers needed are:',
// response.data.required_approving_review_count
// );
// console.log(response.data);
// })
// .catch((error: any) => {
// console.log('Branch protections is not enabled for repository: ' + repo);
// console.log('Error:', error?.message);
// });

//numberOfReviewers > 0, if state of branch protection changes
const numberOfReviewers: number = 0;

// const token: string = core.getInput('github-token');
// const octokit: any = github.getOctokit(token);
const token: string = core.getInput('github-token');
const octokit: any = github.getOctokit(token);

await octokit.rest.repos
.getBranchProtection({
Expand Down

0 comments on commit 94f9056

Please sign in to comment.