Skip to content

Commit

Permalink
getPullRequestEditedDiffRanges: check the number of changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuan-kai Lin committed Jan 13, 2025
1 parent 68b1b4e commit 63d1f4f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,17 @@ async function getPullRequestEditedDiffRanges(
if (fileDiffs === undefined) {
return undefined;
}
if (fileDiffs.length >= 300) {
// The "compare two commits" API returns a maximum of 300 changed files. If
// we see that many changed files, it is possible that there could be more,
// with the rest being truncated. In this case, we should not attempt to
// compute the diff ranges, as the result would be incomplete.
logger.warning(
`Cannot retrieve the full diff because there are too many ` +
`(${fileDiffs.length}) changed files in the pull request.`,
);
return undefined;
}
const results: DiffThunkRange[] = [];
for (const filediff of fileDiffs) {
const diffRanges = getDiffRanges(filediff, logger);
Expand Down

0 comments on commit 63d1f4f

Please sign in to comment.