Skip to content

Commit

Permalink
Merge pull request #12 from dcodx/bug/error-undefined
Browse files Browse the repository at this point in the history
fix error:undefined
  • Loading branch information
david3107 authored Apr 25, 2024
2 parents 47a1283 + e84362d commit 4c45a40
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/evaluators/RepoPolicyEvaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -49564,7 +49564,7 @@ const run = async () => {
core.setFailed(error);
}
else {
Logger_1.logger.error(error);
Logger_1.logger.error(error.message);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const run = async () => {
core.setFailed(error);
}
else {
Logger_1.logger.error(error);
Logger_1.logger.error(error.message);
}
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/github/Repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ export const getRepository = async (
repo: string,
): Promise<Endpoints["GET /repos/{owner}/{repo}"]["response"]["data"]> => {
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 (
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const run = async (): Promise<void> => {
repository,
policies.repo as RepoPolicy,
);

await policyEvaluator.evaluatePolicy();
policyEvaluator.printCheckResults();
report.addOneRepoEvaluator(policyEvaluator);
Expand All @@ -86,7 +86,7 @@ const run = async (): Promise<void> => {
if (process.env.GITHUB_ACTIONS) {
core.setFailed(error);
} else {
logger.error(error);
logger.error(error.message);
}
}
};
Expand Down

0 comments on commit 4c45a40

Please sign in to comment.