github
github copied to clipboard
Default :per_page parameter is ignored
When API instance is created with default :per_page parameter
gh = Github.new :auto_pagination => true, :per_page => 100,...
gh.repos.list
First request is always sent without parameters and autopagination uses default 30 page size.
Hi Serge, do you have time to look into this and submit PR?
I will look into this
We just upgraded from v0.11.3 to v0.12.2 of the gem and were bit by a problem that looks very much like this: when our GitHub connection is initialized with a "default" :per_page setting of 100, branches are missing when they are listed from a repository (i.e. they just don't show up in the resultset). Without setting a "default" :per_page (i.e. if we just don't configure that part), everything is listed correctly.
The difference is that simple:
Causes some branches to be missing from the result:
Github.new do |config|
config.auto_pagination = true
config.oauth_token = @@token
config.per_page = 100
end
Works properly (no branches missing):
Github.new do |config|
config.auto_pagination = true
config.oauth_token = @@token
end
Thanks for letting me know, this is indeed strange behaviour. Does :per_page
work fine when you pass it with your request rather than with global configuration?
github_cli sanity check
$ gcli repo branches USER REPO | fgrep ' name ' | wc -l
173
Without setting .per_page on the connection
pry(main)> github = Github.new do |config|
pry(main)* config.auto_pagination = true
pry(main)* config.oauth_token = token
pry(main)* end
...
pry(main)> github.repos.branches(user, repository).size
173
pry(main)> github.repos.branches(:user => user, :repo => repository).size
173
pry(main)> github.repos.branches(:user => user, :repo => repository, :per_page => 100).size
173
With setting .per_page on the connection
pry(main)> github = Github.new do |config|
pry(main)* config.auto_pagination = true
pry(main)* config.oauth_token = token
pry(main)* config.per_page = 100
pry(main)* end
...
pry(main)> github.repos.branches(user, repository).size
103
pry(main)> github.repos.branches(:user => user, :repo => repository).size
103
pry(main)> github.repos.branches(:user => user, :repo => repository, :per_page => 100).size
173
This problem appears trivially/easily reproducible -- I've never attempted to reproduce it and failed.