From c82bf43d21384301769fc3f9beb3a0d9bed13315 Mon Sep 17 00:00:00 2001 From: Harjot Gill Date: Sun, 16 Apr 2023 23:49:21 -0700 Subject: [PATCH] clarify that old hunk was replaced (#180) ### 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." --- action.yml | 6 +++--- src/review.ts | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index 02931367..dc68b88f 100644 --- a/action.yml +++ b/action.yml @@ -118,7 +118,7 @@ inputs: $description ``` - Content of file `$filename`: + Content of file `$filename` prior to changes: ``` $file_content ``` @@ -181,7 +181,7 @@ inputs: $summary ``` - Content of file `$filename` for context: + Content of `$filename` prior to changes for context: ``` $file_content ``` @@ -209,7 +209,7 @@ inputs: $summary ``` - Content of file: + Content of file prior to changes: ``` $file_content ``` diff --git a/src/review.ts b/src/review.ts index 5d190538..5d9f3d56 100644 --- a/src/review.ts +++ b/src/review.ts @@ -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} \`\`\` @@ -387,17 +387,17 @@ ${ // Pack instructions ins.patches += ` Format for changes: - ---new_hunk_for_review--- + ---new_hunk--- \`\`\` \`\`\` - ---old_hunk_for_context--- + ---old_hunk--- \`\`\` \`\`\` - ---comment_chains_for_context--- + ---comment_chains--- \`\`\` \`\`\` @@ -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 @@ -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 @@ -474,7 +476,7 @@ Response format expected: ... Example changes: - ---new_hunk_for_review--- + ---new_hunk--- 1: def add(x, y): 2: z = x+y 3: retrn z @@ -482,7 +484,7 @@ Example changes: 5: def multiply(x, y): 6: return x * y - ---old_hunk_for_context--- + ---old_hunk--- def add(x, y): return x + y @@ -577,7 +579,7 @@ ${patch} ` if (comment_chain !== '') { ins.patches += ` ----comment_chains_for_review--- +---comment_chains--- \`\`\` ${comment_chain} \`\`\`