Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 33d6f1c

Browse files
authored
update index.js (#390)
1 parent ef6b3ab commit 33d6f1c

File tree

3 files changed

+82
-78
lines changed

3 files changed

+82
-78
lines changed

dist/index.js

Lines changed: 37 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commenter.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ ${COMMENT_TAG}`
231231
}
232232
}
233233

234-
async submitReview(pullNumber: number, commitId: string) {
234+
async submitReview(pullNumber: number, commitId: string, statusMsg: string) {
235235
if (this.reviewCommentsBuffer.length === 0) {
236236
return
237237
}
@@ -297,14 +297,20 @@ ${COMMENT_TAG}`
297297
`Submitting review for PR #${pullNumber}, total comments: ${this.reviewCommentsBuffer.length}, review id: ${review.data.id}`
298298
)
299299

300+
const body = `${COMMENT_GREETING}
301+
302+
${statusMsg}
303+
`
304+
300305
await octokit.pulls.submitReview({
301306
owner: repo.owner,
302307
repo: repo.repo,
303308
// eslint-disable-next-line camelcase
304309
pull_number: pullNumber,
305310
// eslint-disable-next-line camelcase
306311
review_id: review.data.id,
307-
event: 'COMMENT'
312+
event: 'COMMENT',
313+
body
308314
})
309315
} catch (e) {
310316
warning(
@@ -732,11 +738,7 @@ ${chain}
732738
}
733739

734740
// add in-progress status to the comment body
735-
addInProgressStatus(
736-
commentBody: string,
737-
headCommitId: string,
738-
highestReviewedCommitId: string
739-
): string {
741+
addInProgressStatus(commentBody: string, statusMsg: string): string {
740742
const start = commentBody.indexOf(IN_PROGRESS_START_TAG)
741743
const end = commentBody.indexOf(IN_PROGRESS_END_TAG)
742744
// add to the beginning of the comment body if the marker doesn't exist
@@ -746,10 +748,7 @@ ${chain}
746748
747749
Currently reviewing new changes in this PR...
748750
749-
<details>
750-
<summary>Details</summary>
751-
The files that changed from the \`base\` of the PR and between \`${highestReviewedCommitId}\` and \`${headCommitId}\` commits are being reviewed.
752-
</details>
751+
${statusMsg}
753752
754753
${IN_PROGRESS_END_TAG}
755754

src/review.ts

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,37 @@ ${hunks.oldHunk}
262262
return
263263
}
264264

265+
let statusMsg = `<details>
266+
<summary>Commits</summary>
267+
Files that changed from the base of the PR and between ${highestReviewedCommitId} and ${
268+
context.payload.pull_request.head.sha
269+
} commits.
270+
</details>
271+
<details>
272+
<summary>Files selected ${filesAndChanges.length}</summary>
273+
274+
${filesAndChanges
275+
.map(([filename, , , patches]) => `* ${filename} (${patches.length} hunks)`)
276+
.join('\n')}
277+
</details>
278+
${
279+
filterIgnoredFiles.length > 0
280+
? `
281+
<details>
282+
<summary>Files ignored due to filter (${filterIgnoredFiles.length})</summary>
283+
284+
* ${filterIgnoredFiles.map(file => file.filename).join('\n* ')}
285+
286+
</details>
287+
`
288+
: ''
289+
}
290+
`
291+
265292
// update the existing comment with in progress status
266293
const inProgressSummarizeCmt = commenter.addInProgressStatus(
267294
existingSummarizeCmtBody,
268-
context.payload.pull_request.head.sha,
269-
highestReviewedCommitId
295+
statusMsg
270296
)
271297

272298
// add in progress status to the summarize comment
@@ -402,7 +428,7 @@ ${filename}: ${summary}
402428
if (releaseNotesResponse === '') {
403429
info('release notes: nothing obtained from openai')
404430
} else {
405-
let message = '### Summary by CodeRabbit OSS\n\n'
431+
let message = '### Summary by CodeRabbit\n\n'
406432
message += releaseNotesResponse
407433
try {
408434
await commenter.updateDescription(
@@ -446,23 +472,10 @@ ${SHORT_SUMMARY_END_TAG}
446472
### Ignoring further reviews
447473
- Type \`@coderabbitai: ignore\` anywhere in the PR description to ignore further reviews from the bot.
448474
449-
</details>
450-
451-
${
452-
filterIgnoredFiles.length > 0
453-
? `
454-
<details>
455-
<summary>Files ignored due to filter (${filterIgnoredFiles.length})</summary>
456-
457-
### Ignored files
458-
459-
* ${filterIgnoredFiles.map(file => file.filename).join('\n* ')}
460-
461475
</details>
462476
`
463-
: ''
464-
}
465477

478+
statusMsg += `
466479
${
467480
skippedFiles.length > 0
468481
? `
@@ -471,15 +484,12 @@ ${
471484
skippedFiles.length
472485
})</summary>
473486
474-
### Not processed
475-
476487
* ${skippedFiles.join('\n* ')}
477488
478489
</details>
479490
`
480491
: ''
481492
}
482-
483493
${
484494
summariesFailed.length > 0
485495
? `
@@ -488,15 +498,14 @@ ${
488498
summariesFailed.length
489499
})</summary>
490500
491-
### Failed to summarize
492-
493501
* ${summariesFailed.join('\n* ')}
494502
495503
</details>
496504
`
497505
: ''
498506
}
499507
`
508+
500509
if (!options.disableReview) {
501510
const filesAndChangesReview = filesAndChanges.filter(([filename]) => {
502511
const needsReview =
@@ -673,32 +682,25 @@ ${commentChain}
673682

674683
await Promise.all(reviewPromises)
675684

676-
summarizeComment += `
685+
statusMsg += `
677686
${
678687
reviewsFailed.length > 0
679688
? `<details>
680-
<summary>Files not reviewed due to errors in the recent run (${
681-
reviewsFailed.length
682-
})</summary>
683-
684-
### Failed to review in the last run
689+
<summary>Files not reviewed due to errors (${reviewsFailed.length})</summary>
685690
686691
* ${reviewsFailed.join('\n* ')}
687692
688693
</details>
689694
`
690695
: ''
691696
}
692-
693697
${
694698
reviewsSkipped.length > 0
695699
? `<details>
696700
<summary>Files not reviewed due to simple changes (${
697701
reviewsSkipped.length
698702
})</summary>
699703
700-
### Skipped review in the recent run
701-
702704
* ${reviewsSkipped.join('\n* ')}
703705
704706
</details>
@@ -719,7 +721,8 @@ ${
719721
// post the review
720722
await commenter.submitReview(
721723
context.payload.pull_request.number,
722-
commits[commits.length - 1].sha
724+
commits[commits.length - 1].sha,
725+
statusMsg
723726
)
724727
}
725728

0 commit comments

Comments
 (0)