diff --git a/tools/changelog.main.kts b/tools/changelog.main.kts index 93aab47e5c..9f9599e046 100644 --- a/tools/changelog.main.kts +++ b/tools/changelog.main.kts @@ -134,9 +134,10 @@ fun entriesForRepo(repo: String): List { } } - return request("https://api.github.com/repos/$repo/compare/$firstCommit...$lastCommit") - .commits - .map { changelogEntryFor(it, prForCommit(it)) } + return fetchPagedUntilEmpty { page -> + request("https://api.github.com/repos/$repo/compare/$firstCommit...$lastCommit?per_page=1000&page=$page") + .commits + }.map { changelogEntryFor(it, prForCommit(it)) } } /** @@ -265,4 +266,14 @@ fun exponentialRetry(block: () -> T): T { throw exception } +inline fun fetchPagedUntilEmpty(fetch: (page: Int) -> List): MutableList { + val all = mutableListOf() + var page = 1 + do { + val result = fetch(page++) + all.addAll(result) + } while (result.isEmpty()) + return all +} + //endregion \ No newline at end of file