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

Commit

Permalink
clarify that old hunk was replaced (#180)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by openai -->
### Summary by OpenAI

Release Notes:

- Refactor: Update code review instructions and response format for
clarity and consistency.

> "Code review made easy,
> Instructions clear, response format breezy.
> Bugs and issues, we'll catch them all,
> Thanks to this PR, we stand tall."
<!-- end of auto-generated comment: release notes by openai -->
  • Loading branch information
harjotgill authored Apr 17, 2023
1 parent 5850c25 commit c82bf43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inputs:
$description
```
Content of file `$filename`:
Content of file `$filename` prior to changes:
```
$file_content
```
Expand Down Expand Up @@ -181,7 +181,7 @@ inputs:
$summary
```
Content of file `$filename` for context:
Content of `$filename` prior to changes for context:
```
$file_content
```
Expand Down Expand Up @@ -209,7 +209,7 @@ inputs:
$summary
```
Content of file:
Content of file prior to changes:
```
$file_content
```
Expand Down
26 changes: 14 additions & 12 deletions src/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ export const codeReview = async (
continue
}
const hunks_str = `
---new_hunk_for_review---
---new_hunk---
\`\`\`
${hunks.new_hunk}
\`\`\`
---old_hunk_for_context---
---old_hunk---
\`\`\`
${hunks.old_hunk}
\`\`\`
Expand Down Expand Up @@ -387,17 +387,17 @@ ${
// Pack instructions
ins.patches += `
Format for changes:
---new_hunk_for_review---
---new_hunk---
\`\`\`
<new hunk annotated with line numbers>
\`\`\`
---old_hunk_for_context---
---old_hunk---
\`\`\`
<old hunk that was replaced by the new hunk above>
\`\`\`
---comment_chains_for_context---
---comment_chains---
\`\`\`
<comment chains>
\`\`\`
Expand All @@ -406,9 +406,11 @@ Format for changes:
...
The above format for changes consists of multiple change sections.
Each change section consists of a new hunk (annotated with line numbers),
an old hunk (that was replaced with new hunk) and optionally, comment
chains for context.
Each change section consists of a new hunk (annotated with line numbers)
and an old hunk. Note that the code in old_hunk does not exist anymore
as it was replaced by the new hunk. The old_hunk is only included for
context. The new hunk is the code that you should review. Optionally,
existing review comment chains are included for additional context.
Important instructions:
- Your task is to do a line by line review of new hunks and point out
Expand All @@ -434,7 +436,7 @@ Important instructions:
- If needed, provide a replacement suggestion using fenced code blocks
with the \`suggestion\` as the language identifier. The line number range
in the review section must map exactly to the line number range (inclusive)
that need to be replaced within a new_hunk_for_review.
that need to be replaced within a new_hunk.
For instance, if 2 lines of code in a hunk need to be replaced with 15 lines
of code, the line number range must be those exact 2 lines. If an entire hunk
need to be replaced with new code, then the line number range must be the
Expand Down Expand Up @@ -474,15 +476,15 @@ Response format expected:
...
Example changes:
---new_hunk_for_review---
---new_hunk---
1: def add(x, y):
2: z = x+y
3: retrn z
4:
5: def multiply(x, y):
6: return x * y
---old_hunk_for_context---
---old_hunk---
def add(x, y):
return x + y
Expand Down Expand Up @@ -577,7 +579,7 @@ ${patch}
`
if (comment_chain !== '') {
ins.patches += `
---comment_chains_for_review---
---comment_chains---
\`\`\`
${comment_chain}
\`\`\`
Expand Down

0 comments on commit c82bf43

Please sign in to comment.