* Validate review-comment locations against the current PR diff. * Comments that cannot be placed inline are returned separately for general posting.
( octokit: Octokit, context: PullRequestContext, comments: Comment[], )
| 150 | * Comments that cannot be placed inline are returned separately for general posting. |
| 151 | */ |
| 152 | async function partitionReviewCommentsWithOctokit( |
| 153 | octokit: Octokit, |
| 154 | context: PullRequestContext, |
| 155 | comments: Comment[], |
| 156 | ): Promise<{ |
| 157 | lineComments: Comment[]; |
| 158 | generalComments: Comment[]; |
| 159 | invalidLineComments: Comment[]; |
| 160 | }> { |
| 161 | const validRanges = await getPRDiffRanges(octokit, context); |
| 162 | const lineComments: Comment[] = []; |
| 163 | const generalComments: Comment[] = []; |
| 164 | const invalidLineComments: Comment[] = []; |
| 165 | |
| 166 | for (const comment of comments) { |
| 167 | if (!comment.file || comment.line == null) { |
| 168 | generalComments.push(comment); |
| 169 | continue; |
| 170 | } |
| 171 | |
| 172 | const clamped = clampCommentToValidRange(comment, validRanges); |
| 173 | if (clamped) { |
| 174 | lineComments.push(clamped); |
| 175 | } else { |
| 176 | core.warning( |
| 177 | `Comment on ${comment.file}:${comment.line} could not be placed in diff - converting to general comment`, |
| 178 | ); |
| 179 | invalidLineComments.push(comment); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return { lineComments, generalComments, invalidLineComments }; |
| 184 | } |
| 185 | |
| 186 | export async function partitionReviewCommentsByDiff( |
| 187 | token: string, |
no test coverage detected
searching dependent graphs…