Better comments and removed superfluous logic.

This commit is contained in:
Jimmy Royer 2024-09-20 17:32:54 -04:00
parent 1565f8f40e
commit e7ec594512
3 changed files with 7 additions and 7 deletions

6
dist/index.js vendored
View file

@ -176,10 +176,8 @@ require("./sourcemap-register.js");
case "opened": case "opened":
case "synchronize": case "synchronize":
return getPrFromEvent(eventData); return getPrFromEvent(eventData);
break;
case "push": case "push":
return getPrFromApi(eventData); return getPrFromApi(eventData);
break;
default: default:
throw new Error(`Unsupported event: action=${eventName}`); throw new Error(`Unsupported event: action=${eventName}`);
} }
@ -585,7 +583,9 @@ ${chunk.changes
const filteredDiff = filterDiffs(parsedDiff); const filteredDiff = filterDiffs(parsedDiff);
const comments = yield analyzeCode(filteredDiff, prDetails); const comments = yield analyzeCode(filteredDiff, prDetails);
if (comments.length > 0) { if (comments.length > 0) {
// Additional logging and validation before creating the review // We want to log the comments to be posted for debugging purposes, as
// we see errors when used in the actual workflow but cannot figure out
// why without seeing these logged comments.
comments.forEach((comment) => { comments.forEach((comment) => {
console.log( console.log(
`Comment to be posted: ${comment.body} at ${comment.path}:${comment.line}` `Comment to be posted: ${comment.body} at ${comment.path}:${comment.line}`

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -92,10 +92,8 @@ async function getPrDetails(
case "opened": case "opened":
case "synchronize": case "synchronize":
return getPrFromEvent(eventData); return getPrFromEvent(eventData);
break;
case "push": case "push":
return getPrFromApi(eventData); return getPrFromApi(eventData);
break;
default: default:
throw new Error(`Unsupported event: action=${eventName}`); throw new Error(`Unsupported event: action=${eventName}`);
} }
@ -486,7 +484,9 @@ async function main() {
const comments = await analyzeCode(filteredDiff, prDetails); const comments = await analyzeCode(filteredDiff, prDetails);
if (comments.length > 0) { if (comments.length > 0) {
// Additional logging and validation before creating the review // We want to log the comments to be posted for debugging purposes, as
// we see errors when used in the actual workflow but cannot figure out
// why without seeing these logged comments.
comments.forEach((comment) => { comments.forEach((comment) => {
console.log( console.log(
`Comment to be posted: ${comment.body} at ${comment.path}:${comment.line}` `Comment to be posted: ${comment.body} at ${comment.path}:${comment.line}`