1

When calling the GitHub API with Octokit to get all ahead commits of a fork repo by comparing each of their branches together, if the fork repo contains more than 300 commits ahead then octokit only returns a maximum of 250. I have searched the entire Internet but still have no clue. Does anyone know how to bypass this limit? Any help would be appreciate

Thinh Tran
  • 776
  • 1
  • 7
  • 11

1 Answers1

0

You might consider adding octokit/plugin-paginate-rest.js in order to include pagination to your results

The per_page parameter is usually defaulting to 30, and can be set to up to 100, which helps retrieving a big amount of data without hitting the rate limits too soon.

An optional mapFunction can be passed to map each page response to a new value, usually an array with only the data you need.
This can help to reduce memory usage, as only the relevant data has to be kept in memory until the pagination is complete.

const issueTitles = await octokit.paginate(
 "GET /repos/{owner}/{repo}/issues",
 {
   owner: "octocat",
   repo: "hello-world",
   since: "2010-10-01",
   per_page: 100,
 },
 (response) => response.data.map((issue) => issue.title)
);
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250