feat: Refactor code to separate functions for creating review comments, analyzing code, getting PR details, getting AI response, creating comments, and getting diffs.

This commit is contained in:
Will Hohyon Ryu 2024-03-07 19:16:09 -08:00
parent 751c4e51f9
commit c30f272ef1
8 changed files with 202 additions and 187 deletions

21
src/createComment.ts Normal file
View file

@ -0,0 +1,21 @@
import {Chunk, File} from "parse-diff";
export function createComment(
file: File,
chunk: Chunk,
aiResponses: Array<{
lineNumber: string;
reviewComment: string;
}>
): Array<{ body: string; path: string; line: number }> {
return aiResponses.flatMap((aiResponse) => {
if (!file.to) {
return [];
}
return {
body: aiResponse.reviewComment,
path: file.to,
line: Number(aiResponse.lineNumber),
};
});
}