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

Max files #214

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
description:
'Max files to summarize and review. Less than or equal to 0 means no
limit.'
default: '0'
default: '150'
review_comment_lgtm:
required: false
description: 'Leave comments even if the patch is LGTM'
Expand Down
43 changes: 20 additions & 23 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,22 @@ export class Prompts {
render_summarize_file_diff(inputs: Inputs): string {
const prompt = `${this.summarize_file_diff}

Below the summary, I would also like you to classify the complexity
of the diff as \`COMPLEX\` or \`SIMPLE\` based on the following
Below the summary, I would also like you to triage the diff
as \`NEEDS_REVIEW\` or \`APPROVED\` based on the following
criteria:

- If the diff introduces new functionality, modifies existing logic
significantly, or has potential security implications,
classify it as \`COMPLEX\`.
- If the diff introduces new functionality, modifies existing logic,
or has potential for bugs, triage it as \`NEEDS_REVIEW\`.
- If the diff only contains minor changes, such as fixing typos,
formatting, or updating documentation, classify it as \`SIMPLE\`.
formatting, renaming variables, triage it as \`APPROVED\`.

Please evaluate the diff thoroughly and take into account factors
such as the number of lines changed, the potential impact on the
overall system, and the likelihood of introducing new bugs or
security vulnerabilities.
harjotgill marked this conversation as resolved.
Show resolved Hide resolved

Use the following format to classify the complexity of the diff
and add no additional text:
[COMPLEXITY]: <COMPLEX or SIMPLE>
Use the following format to triage the diff and add no additional text:
[TRIAGE]: <NEEDS_REVIEW or APPROVED>
`

return inputs.render(prompt)
Expand Down
27 changes: 13 additions & 14 deletions src/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,21 @@ ${hunks.old_hunk}
summaries_failed.push(`${filename} (nothing obtained from openai)`)
return null
} else {
// parse the comment to look for complexity classification
// Format is : [COMPLEXITY]: <COMPLEX or SIMPLE>
// if the change is complex return true, else false
const complexityRegex = /\[COMPLEXITY\]:\s*(COMPLEX|SIMPLE)/
const complexityMatch = summarize_resp.match(complexityRegex)
// parse the comment to look for triage classification
// Format is : [TRIAGE]: <NEEDS_REVIEW or APPROVED>
// if the change needs review return true, else false
const triageRegex = /\[TRIAGE\]:\s*(NEEDS_REVIEW|APPROVED)/
const triageMatch = summarize_resp.match(triageRegex)

if (complexityMatch) {
const complexity = complexityMatch[1]
const is_complex = complexity === 'COMPLEX' ? true : false
if (triageMatch) {
const triage = triageMatch[1]
const needs_review = triage === 'NEEDS_REVIEW' ? true : false

// remove this line from the comment
const summary = summarize_resp.replace(complexityRegex, '').trim()
core.info(`filename: ${filename}, complexity: ${complexity}`)
return [filename, summary, is_complex]
const summary = summarize_resp.replace(triageRegex, '').trim()
core.info(`filename: ${filename}, triage: ${triage}`)
return [filename, summary, needs_review]
} else {
// Handle the case when the [COMPLEXITY] tag is not found
return [filename, summarize_resp, true]
}
}
Expand Down Expand Up @@ -439,11 +438,11 @@ ${

if (options.summary_only !== true) {
const files_and_changes_review = files_and_changes.filter(([filename]) => {
const is_complex =
const needs_review =
summaries.find(
([summaryFilename]) => summaryFilename === filename
)?.[2] ?? true
return is_complex
return needs_review
})

const reviews_skipped = files_and_changes
Expand Down