utils/github: API.paginate_rest handles extra query params
- Functionally it doesn't matter that the URL will have an `&` at the end if `additional_query_params` is `nil`, because it doesn't affect the URL at all.
This commit is contained in:
parent
0a6c59c0b3
commit
c9e6b81b4b
@ -704,7 +704,7 @@ module GitHub # rubocop:disable Metrics/ModuleLength
|
||||
return if Homebrew::EnvConfig.no_github_api?
|
||||
|
||||
commits = 0
|
||||
API.paginate_rest("#{API_URL}/repos/#{nwo}/commits", query: "&author=#{user}") do |result|
|
||||
API.paginate_rest("#{API_URL}/repos/#{nwo}/commits", additional_query_params: "author=#{user}") do |result|
|
||||
commits += result.length
|
||||
end
|
||||
commits
|
||||
|
||||
@ -253,9 +253,9 @@ module GitHub
|
||||
end
|
||||
end
|
||||
|
||||
def paginate_rest(url, query: nil, per_page: 100)
|
||||
def paginate_rest(url, additional_query_params: nil, per_page: 100)
|
||||
(1..API_MAX_PAGES).each do |page|
|
||||
result = API.open_rest("#{url}?per_page=#{per_page}&page=#{page}#{query}")
|
||||
result = API.open_rest("#{url}?per_page=#{per_page}&page=#{page}&#{additional_query_params}")
|
||||
yield(result, page)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user