Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit b103de3

Browse files
authored
allow max files no limit option (#31)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Release Notes** This pull request adds new features to the codebase that allow users to exclude certain files from being reviewed and specify the maximum number of files to be reviewed. The `max_files` option has been added to `README.md` and the default value has been changed from 30 to 40 in `src/options.ts`. A new `exclude_paths` option has been added to `src/review.ts` to support excluding files from review. <!-- end of auto-generated comment: release notes by openai -->
1 parent a89d11c commit b103de3

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ See also: [./action.yml](./action.yml)
8888

8989
- `debug`: Enable debug mode, will show messages and responses between OpenAI
9090
server in CI logs.
91+
- `max_files`: Maximum number of files to be reviewed. Less than or equal to 0
92+
means no limit.
9193
- `review_comment_lgtm`: Leave comments even the patch is LGTM
9294
- `path_filters`: Rules to filter files to be reviewed.
9395
- `temperature`: Temperature of the GPT-3 model.

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ inputs:
1111
default: 'false'
1212
max_files:
1313
required: false
14-
description: 'Max files to review'
15-
default: '30'
14+
description: 'Max files to review. Less than or equal to 0 means no limit.'
15+
default: '40'
1616
temperature:
1717
required: false
1818
description: 'Temperature for GPT model'

dist/index.js

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class Options {
149149

150150
constructor(
151151
debug: boolean,
152-
max_files = '30',
152+
max_files = '40',
153153
review_comment_lgtm = false,
154154
path_filters: string[] | null = null,
155155
system_message = '',

src/review.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,19 @@ export const codeReview = async (
6666
return
6767
}
6868

69-
// check if we are exceeding max_files
70-
if (files.length > options.max_files) {
69+
// skip files if they are filtered out
70+
const filtered_files = []
71+
for (const file of files) {
72+
if (!options.check_path(file.filename)) {
73+
core.info(`skip for excluded path: ${file.filename}`)
74+
continue
75+
} else {
76+
filtered_files.push(file)
77+
}
78+
}
79+
80+
// check if we are exceeding max_files and if max_files is <= 0 (no limit)
81+
if (filtered_files.length > options.max_files && options.max_files > 0) {
7182
core.warning("Skipped: too many files to review, can't handle it")
7283
await commenter.comment(
7384
`Skipped: too many files to review, can't handle it`,
@@ -79,11 +90,7 @@ export const codeReview = async (
7990

8091
// find patches to review
8192
const files_to_review: [string, string, string, [number, string][]][] = []
82-
for (const file of files) {
83-
if (!options.check_path(file.filename)) {
84-
core.info(`skip for excluded path: ${file.filename}`)
85-
continue
86-
}
93+
for (const file of filtered_files) {
8794
// retrieve file contents
8895
let file_content = ''
8996
try {

0 commit comments

Comments
 (0)