MCPcopy
hub / github.com/promptfoo/promptfoo / partitionReviewCommentsWithOctokit

Function partitionReviewCommentsWithOctokit

code-scan-action/src/github.ts:152–184  ·  view source on GitHub ↗

* 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[],
)

Source from the content-addressed store, hash-verified

150 * Comments that cannot be placed inline are returned separately for general posting.
151 */
152async 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
186export async function partitionReviewCommentsByDiff(
187 token: string,

Callers 1

Calls 3

getPRDiffRangesFunction · 0.85
clampCommentToValidRangeFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…