mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 10:06:47 +00:00
CICO-111286: Handle error on duplicate review comments
This commit is contained in:
parent
51393ab4c1
commit
d129a930b3
3 changed files with 21 additions and 5 deletions
13
src/main.ts
13
src/main.ts
|
@ -8,7 +8,7 @@ import minimatch from "minimatch";
|
|||
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
||||
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
||||
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
||||
const FRAMEWORK: string = core.getInput("framework"); // New input for framework
|
||||
const FRAMEWORK: string = core.getInput("framework");
|
||||
|
||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||
|
||||
|
@ -469,12 +469,21 @@ async function createReviewComment(
|
|||
pull_number: number,
|
||||
comments: Array<{ body: string; path: string; line: number }>
|
||||
): Promise<void> {
|
||||
const validComments = comments.filter(comment => comment.path && comment.line > 0 && comment.body.trim() !== "");
|
||||
|
||||
if (validComments.length === 0) {
|
||||
console.log("No valid comments to add");
|
||||
return;
|
||||
}
|
||||
|
||||
await octokit.pulls.createReview({
|
||||
owner,
|
||||
repo,
|
||||
pull_number,
|
||||
comments,
|
||||
comments: validComments,
|
||||
event: "COMMENT",
|
||||
}).catch(error => {
|
||||
console.error("Error creating review comment:", error);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue