mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 01:56:47 +00:00
CICO-111286: Fix error with dup comment
This commit is contained in:
parent
d129a930b3
commit
33810674fc
3 changed files with 48 additions and 17 deletions
32
dist/index.js
vendored
32
dist/index.js
vendored
|
@ -114,16 +114,21 @@ function analyzeCode(parsedDiff, prDetails, existingComments) {
|
||||||
if (aiResponse) {
|
if (aiResponse) {
|
||||||
const newComments = createComment(file, chunk, aiResponse);
|
const newComments = createComment(file, chunk, aiResponse);
|
||||||
for (const comment of newComments) {
|
for (const comment of newComments) {
|
||||||
|
console.log("Processing comment:", comment);
|
||||||
const duplicate = existingComments.some(existingComment => existingComment.path === comment.path &&
|
const duplicate = existingComments.some(existingComment => existingComment.path === comment.path &&
|
||||||
existingComment.line === comment.line &&
|
existingComment.line === comment.line &&
|
||||||
existingComment.body.trim() === comment.body.trim());
|
existingComment.body.trim() === comment.body.trim());
|
||||||
if (!duplicate) {
|
if (!duplicate) {
|
||||||
comments.push(comment);
|
comments.push(comment);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
console.log("Duplicate comment found, skipping:", comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("Final comments to add:", JSON.stringify(comments, null, 2));
|
||||||
return comments;
|
return comments;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -467,15 +472,26 @@ function createReviewComment(owner, repo, pull_number, comments) {
|
||||||
console.log("No valid comments to add");
|
console.log("No valid comments to add");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yield octokit.pulls.createReview({
|
console.log("Attempting to create review comments:", JSON.stringify(validComments, null, 2));
|
||||||
owner,
|
try {
|
||||||
repo,
|
yield octokit.pulls.createReview({
|
||||||
pull_number,
|
owner,
|
||||||
comments: validComments,
|
repo,
|
||||||
event: "COMMENT",
|
pull_number,
|
||||||
}).catch(error => {
|
comments: validComments,
|
||||||
|
event: "COMMENT",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
console.error("Error creating review comment:", error);
|
console.error("Error creating review comment:", error);
|
||||||
});
|
console.log("Request data:", {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
pull_number,
|
||||||
|
comments: validComments,
|
||||||
|
event: "COMMENT",
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function main() {
|
function main() {
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
31
src/main.ts
31
src/main.ts
|
@ -91,6 +91,7 @@ async function analyzeCode(
|
||||||
if (aiResponse) {
|
if (aiResponse) {
|
||||||
const newComments = createComment(file, chunk, aiResponse);
|
const newComments = createComment(file, chunk, aiResponse);
|
||||||
for (const comment of newComments) {
|
for (const comment of newComments) {
|
||||||
|
console.log("Processing comment:", comment);
|
||||||
const duplicate = existingComments.some(
|
const duplicate = existingComments.some(
|
||||||
existingComment =>
|
existingComment =>
|
||||||
existingComment.path === comment.path &&
|
existingComment.path === comment.path &&
|
||||||
|
@ -99,11 +100,14 @@ async function analyzeCode(
|
||||||
);
|
);
|
||||||
if (!duplicate) {
|
if (!duplicate) {
|
||||||
comments.push(comment);
|
comments.push(comment);
|
||||||
|
} else {
|
||||||
|
console.log("Duplicate comment found, skipping:", comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("Final comments to add:", JSON.stringify(comments, null, 2));
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,15 +480,26 @@ async function createReviewComment(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await octokit.pulls.createReview({
|
console.log("Attempting to create review comments:", JSON.stringify(validComments, null, 2));
|
||||||
owner,
|
|
||||||
repo,
|
try {
|
||||||
pull_number,
|
await octokit.pulls.createReview({
|
||||||
comments: validComments,
|
owner,
|
||||||
event: "COMMENT",
|
repo,
|
||||||
}).catch(error => {
|
pull_number,
|
||||||
|
comments: validComments,
|
||||||
|
event: "COMMENT",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
console.error("Error creating review comment:", error);
|
console.error("Error creating review comment:", error);
|
||||||
});
|
console.log("Request data:", {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
pull_number,
|
||||||
|
comments: validComments,
|
||||||
|
event: "COMMENT",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue