github-tools / github

A higher-level wrapper around the Github API. Intended for the browser.
BSD 3-Clause "New" or "Revised" License
3.6k stars 755 forks source link

listBranches() does not return all branches in a repository #592

Open timgcarlson opened 4 years ago

timgcarlson commented 4 years ago

When using listBranches() on a repository with over 30 branches, I only get 30 branches in the response. The response includes the page information:

link: '<https://api.github.com/repositories/0000000/branches?page=2>; rel="next", <https://api.github.com/repositories/0000000/branches?page=2>; rel="last"',

However, I do not see a way to include options on the listBranches() function. Is it currently possible to get back all the branches in the repository?

EDIT: This might be a duplicate of this feature request.

timgcarlson commented 4 years ago

I'm able to get all the branches if I use _requestAllPages and __fullname:

let repo = githubApi.getRepo(user, repo)
repo._requestAllPages(`/repos/${this._repo.__fullname}/branches`, { AcceptHeader: 'inertia-preview' })
    .then(response => console.log('all branches:', response.data));

Is this going to be my only solution without updating this wrapper? I'm happy to submit a PR if this is a feature that could be added. Perhaps including an option to use _requestAllPages when needed, but defaulting to not use it to avoid rate limits.

j-rewerts commented 4 years ago

This is related to a larger issue around paging. We have quite a few issues for paging, but I'd like to leave this open to ensure it gets dealt with. See #578.

j-rewerts commented 4 years ago

PRs are welcome, btw! Also, discussion around how we're going to handle paging would be welcome. Comment in #578 if you're interested.