remove duplicate deletion and addition signs

This commit is contained in:
Ville Saukkonen 2023-03-23 20:40:05 +02:00
parent 6293b88dcd
commit 30597b305c
3 changed files with 19 additions and 13 deletions

19
dist/index.js vendored

@ -105,8 +105,7 @@ function analyzeCode(parsedDiff, prDetails) {
}); });
} }
function createPrompt(file, chunk, prDetails) { function createPrompt(file, chunk, prDetails) {
return ` return `Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
Title: ${prDetails.title} Title: ${prDetails.title}
@ -120,12 +119,22 @@ Please provide comments and suggestions ONLY if there is something to improve, w
Diff to review: Diff to review:
--- \`\`\`diff
${chunk.content} ${chunk.content}
${chunk.changes ${chunk.changes
.map((c) => (c.type === "add" ? "+" : "-") + " " + c.content) .map((c) => {
if (c.type === "add") {
return "+ " + c.content;
}
else if (c.type === "del") {
return "- " + c.content;
}
else {
return " " + c.content;
}
})
.join("\n")} .join("\n")}
--- \`\`\`
Give the answer in following TSV format: Give the answer in following TSV format:
line_number\treview_comment line_number\treview_comment

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

@ -80,8 +80,7 @@ async function analyzeCode(
} }
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string { function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
return ` return `Review the following code diff in the file "${
Review the following code diff in the file "${
file.to file.to
}" and take the pull request title and description into account when writing the response. }" and take the pull request title and description into account when writing the response.
@ -97,12 +96,10 @@ Please provide comments and suggestions ONLY if there is something to improve, w
Diff to review: Diff to review:
--- \`\`\`diff
${chunk.content} ${chunk.content}
${chunk.changes ${chunk.changes.map((c) => c.content).join("\n")}
.map((c) => (c.type === "add" ? "+" : "-") + " " + c.content) \`\`\`
.join("\n")}
---
Give the answer in following TSV format: Give the answer in following TSV format:
line_number\treview_comment line_number\treview_comment