Skip to content

Commit 63d1f4f

Browse files
committed
getPullRequestEditedDiffRanges: check the number of changed files
1 parent 68b1b4e commit 63d1f4f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/analyze.ts

+11
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ async function getPullRequestEditedDiffRanges(
298298
if (fileDiffs === undefined) {
299299
return undefined;
300300
}
301+
if (fileDiffs.length >= 300) {
302+
// The "compare two commits" API returns a maximum of 300 changed files. If
303+
// we see that many changed files, it is possible that there could be more,
304+
// with the rest being truncated. In this case, we should not attempt to
305+
// compute the diff ranges, as the result would be incomplete.
306+
logger.warning(
307+
`Cannot retrieve the full diff because there are too many ` +
308+
`(${fileDiffs.length}) changed files in the pull request.`,
309+
);
310+
return undefined;
311+
}
301312
const results: DiffThunkRange[] = [];
302313
for (const filediff of fileDiffs) {
303314
const diffRanges = getDiffRanges(filediff, logger);

0 commit comments

Comments
 (0)