github icon indicating copy to clipboard operation
github copied to clipboard

listBranches() does not return all branches in a repository

Open timgcarlson opened this issue 5 years ago • 3 comments

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 avatar Oct 03 '19 00:10 timgcarlson

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.

timgcarlson avatar Oct 03 '19 19:10 timgcarlson

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 avatar Oct 08 '19 13:10 j-rewerts

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

j-rewerts avatar Oct 08 '19 13:10 j-rewerts