Skip to content

Commit

Permalink
add comment counts in review summary (coderabbitai#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
harjotgill authored Jul 31, 2023
1 parent e371e3a commit 56173d9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
21 changes: 18 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions src/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,19 @@ Files that changed from the base of the PR and between ${highestReviewedCommitId
context.payload.pull_request.head.sha
} commits.
</details>
${
filesAndChanges.length > 0
? `
<details>
<summary>Files selected (${filesAndChanges.length})</summary>
${filesAndChanges
.map(([filename, , , patches]) => `* ${filename} (${patches.length} hunks)`)
.join('\n')}
* ${filesAndChanges
.map(([filename, , , patches]) => `${filename} (${patches.length})`)
.join('\n* ')}
</details>
`
: ''
}
${
filterIgnoredFiles.length > 0
? `
Expand Down Expand Up @@ -526,6 +532,8 @@ ${

// failed reviews array
const reviewsFailed: string[] = []
let lgtmCount = 0
let reviewCount = 0
const doReview = async (
filename: string,
fileContent: string,
Expand Down Expand Up @@ -640,6 +648,7 @@ ${commentChain}
(review.comment.includes('LGTM') ||
review.comment.includes('looks good to me'))
) {
lgtmCount += 1
continue
}
if (context.payload.pull_request == null) {
Expand All @@ -648,6 +657,7 @@ ${commentChain}
}

try {
reviewCount += 1
await commenter.bufferReviewComment(
filename,
review.startLine,
Expand Down Expand Up @@ -711,6 +721,13 @@ ${
`
: ''
}
<details>
<summary>Review comments generated (${reviewCount + lgtmCount})</summary>
* Review: ${reviewCount}
* LGTM: ${lgtmCount}
</details>
`
// add existing_comment_ids_block with latest head sha
summarizeComment += `\n${commenter.addReviewedCommitId(
Expand Down

0 comments on commit 56173d9

Please sign in to comment.