diff --git a/README.md b/README.md index c962655f..35b1e2ea 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ See also: [./action.yml](./action.yml) - `debug`: Enable debug mode, will show messages and responses between OpenAI server in CI logs. +- `max_files`: Maximum number of files to be reviewed. Less than or equal to 0 + means no limit. - `review_comment_lgtm`: Leave comments even the patch is LGTM - `path_filters`: Rules to filter files to be reviewed. - `temperature`: Temperature of the GPT-3 model. diff --git a/action.yml b/action.yml index 6110723a..99474c4d 100644 --- a/action.yml +++ b/action.yml @@ -11,8 +11,8 @@ inputs: default: 'false' max_files: required: false - description: 'Max files to review' - default: '30' + description: 'Max files to review. Less than or equal to 0 means no limit.' + default: '40' temperature: required: false description: 'Temperature for GPT model' diff --git a/dist/index.js b/dist/index.js index 588d23ba..28fb863b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28702,7 +28702,7 @@ class Options { path_filters; system_message; temperature; - constructor(debug, max_files = '30', review_comment_lgtm = false, path_filters = null, system_message = '', temperature = '0.0') { + constructor(debug, max_files = '40', review_comment_lgtm = false, path_filters = null, system_message = '', temperature = '0.0') { this.debug = debug; this.max_files = parseInt(max_files); this.review_comment_lgtm = review_comment_lgtm; @@ -29087,19 +29087,26 @@ const codeReview = async (bot, options, prompts) => { await commenter.comment(`Skipped: no files to review`, comment_tag, 'replace'); return; } - // check if we are exceeding max_files - if (files.length > options.max_files) { + // skip files if they are filtered out + const filtered_files = []; + for (const file of files) { + if (!options.check_path(file.filename)) { + core.info(`skip for excluded path: ${file.filename}`); + continue; + } + else { + filtered_files.push(file); + } + } + // check if we are exceeding max_files and if max_files is <= 0 (no limit) + if (filtered_files.length > options.max_files && options.max_files > 0) { core.warning("Skipped: too many files to review, can't handle it"); await commenter.comment(`Skipped: too many files to review, can't handle it`, comment_tag, 'replace'); return; } // find patches to review const files_to_review = []; - for (const file of files) { - if (!options.check_path(file.filename)) { - core.info(`skip for excluded path: ${file.filename}`); - continue; - } + for (const file of filtered_files) { // retrieve file contents let file_content = ''; try { diff --git a/src/options.ts b/src/options.ts index 87deb758..d5b9346b 100644 --- a/src/options.ts +++ b/src/options.ts @@ -149,7 +149,7 @@ export class Options { constructor( debug: boolean, - max_files = '30', + max_files = '40', review_comment_lgtm = false, path_filters: string[] | null = null, system_message = '', diff --git a/src/review.ts b/src/review.ts index 5e0a02d0..9ae25b72 100644 --- a/src/review.ts +++ b/src/review.ts @@ -66,8 +66,19 @@ export const codeReview = async ( return } - // check if we are exceeding max_files - if (files.length > options.max_files) { + // skip files if they are filtered out + const filtered_files = [] + for (const file of files) { + if (!options.check_path(file.filename)) { + core.info(`skip for excluded path: ${file.filename}`) + continue + } else { + filtered_files.push(file) + } + } + + // check if we are exceeding max_files and if max_files is <= 0 (no limit) + if (filtered_files.length > options.max_files && options.max_files > 0) { core.warning("Skipped: too many files to review, can't handle it") await commenter.comment( `Skipped: too many files to review, can't handle it`, @@ -79,11 +90,7 @@ export const codeReview = async ( // find patches to review const files_to_review: [string, string, string, [number, string][]][] = [] - for (const file of files) { - if (!options.check_path(file.filename)) { - core.info(`skip for excluded path: ${file.filename}`) - continue - } + for (const file of filtered_files) { // retrieve file contents let file_content = '' try {