mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-20 17:46:47 +00:00
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:
parent
751c4e51f9
commit
c30f272ef1
8 changed files with 202 additions and 187 deletions
21
src/createComment.ts
Normal file
21
src/createComment.ts
Normal 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),
|
||||
};
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue