From 7e3437b9881bc54bdb5b8b577a148d228d57f655 Mon Sep 17 00:00:00 2001 From: Davide Cioccia Date: Thu, 25 Apr 2024 09:05:35 +0200 Subject: [PATCH 1/2] fix error:undefined --- dist/evaluators/RepoPolicyEvaluator.js | 2 +- dist/index.js | 5 +++-- dist/main.js | 3 ++- src/github/Repositories.ts | 5 +++-- src/main.ts | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dist/evaluators/RepoPolicyEvaluator.js b/dist/evaluators/RepoPolicyEvaluator.js index e0dc7c4..9637e31 100644 --- a/dist/evaluators/RepoPolicyEvaluator.js +++ b/dist/evaluators/RepoPolicyEvaluator.js @@ -40,7 +40,7 @@ class RepoPolicyEvaluator { this.repositoryCheckResults.push(branch_protection_pull_request_results); } // Check the files exist policy rule - if (this.policy.file_exists.length > 0) { + if (this.policy.file_exists && this.policy.file_exists.length > 0) { const files_exist = await new FilesExistChecks_1.FilesExistChecks(this.repository, this.policy).checkFilesExist(); Logger_1.logger.debug(`Files exists results: ${JSON.stringify(files_exist)}`); this.repositoryCheckResults.push(files_exist); diff --git a/dist/index.js b/dist/index.js index 708c4c5..8987db3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -47908,7 +47908,7 @@ class RepoPolicyEvaluator { this.repositoryCheckResults.push(branch_protection_pull_request_results); } // Check the files exist policy rule - if (this.policy.file_exists.length > 0) { + if (this.policy.file_exists && this.policy.file_exists.length > 0) { const files_exist = await new FilesExistChecks_1.FilesExistChecks(this.repository, this.policy).checkFilesExist(); Logger_1.logger.debug(`Files exists results: ${JSON.stringify(files_exist)}`); this.repositoryCheckResults.push(files_exist); @@ -49564,7 +49564,8 @@ const run = async () => { core.setFailed(error); } else { - Logger_1.logger.error(error); + console.log(error.status); + Logger_1.logger.error(error.message); } } }; diff --git a/dist/main.js b/dist/main.js index 8140469..e6a5893 100644 --- a/dist/main.js +++ b/dist/main.js @@ -90,7 +90,8 @@ const run = async () => { core.setFailed(error); } else { - Logger_1.logger.error(error); + console.log(error.status); + Logger_1.logger.error(error.message); } } }; diff --git a/src/github/Repositories.ts b/src/github/Repositories.ts index af7194b..8c8a6f4 100644 --- a/src/github/Repositories.ts +++ b/src/github/Repositories.ts @@ -28,14 +28,15 @@ export const getRepository = async ( repo: string, ): Promise => { const octokit = new GitArmorKit(); - + const response: Endpoints["GET /repos/{owner}/{repo}"]["response"] = await octokit.rest.repos.get({ owner: owner, repo: repo, }); - + return response.data; + }; export const getRepoPullRequests = async ( diff --git a/src/main.ts b/src/main.ts index a5e0177..270b4de 100644 --- a/src/main.ts +++ b/src/main.ts @@ -64,7 +64,7 @@ const run = async (): Promise => { repository, policies.repo as RepoPolicy, ); - + await policyEvaluator.evaluatePolicy(); policyEvaluator.printCheckResults(); report.addOneRepoEvaluator(policyEvaluator); @@ -86,7 +86,7 @@ const run = async (): Promise => { if (process.env.GITHUB_ACTIONS) { core.setFailed(error); } else { - logger.error(error); + logger.error(error.message); } } }; From e84362d3691f84ca1ce2a377d936f351eb4353b0 Mon Sep 17 00:00:00 2001 From: Davide Cioccia Date: Thu, 25 Apr 2024 09:08:04 +0200 Subject: [PATCH 2/2] fix error:undefined in dist --- dist/index.js | 1 - dist/main.js | 1 - 2 files changed, 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8987db3..6aba795 100644 --- a/dist/index.js +++ b/dist/index.js @@ -49564,7 +49564,6 @@ const run = async () => { core.setFailed(error); } else { - console.log(error.status); Logger_1.logger.error(error.message); } } diff --git a/dist/main.js b/dist/main.js index e6a5893..987fde7 100644 --- a/dist/main.js +++ b/dist/main.js @@ -90,7 +90,6 @@ const run = async () => { core.setFailed(error); } else { - console.log(error.status); Logger_1.logger.error(error.message); } }