Skip to content
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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roast-my-code",
"version": "1.2.0",
"version": "1.3.0",
"description": "mean and aggressive code reviews by ChatGPT",
"main": "lib/main.js",
"author": "Christina Martinez, based on work by Ville Saukkonen",
Expand Down
27 changes: 21 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,31 @@ function createComment(
reviewComment: string;
}>
): Array<{ body: string; path: string; line: number }> {
return aiResponses.flatMap((aiResponse) => {
const comments = aiResponses.flatMap((aiResponse) => {
if (!file.to) {
return [];
}
return {
body: aiResponse.reviewComment,
path: file.to,
line: Number(aiResponse.lineNumber),
};
const lineNumber = Number(aiResponse.lineNumber);
if (
chunk.changes.some(
(change: any) =>
change.ln === lineNumber || change.ln2 === lineNumber
)
) {
return {
body: aiResponse.reviewComment,
path: file.to,
line: lineNumber,
};
} else {
console.warn(
`Line number ${lineNumber} does not exist in the diff for file ${file.to}`
);
return [];
}
});
console.log("Comments:", comments);
return comments;
}

async function createReviewComment(
Expand Down
Loading