github
github copied to clipboard
listBranches() does not return all branches in a repository
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.
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.
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.
PRs are welcome, btw! Also, discussion around how we're going to handle paging would be welcome. Comment in #578 if you're interested.