Commit 0a7678b5 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix/github-importer-client' into 'master'

Fix broken handling of certain calls in GitHub importer client

## What does this MR do?
It changes/fixes the behavior of request handling in GH client. Now it returns the response directly if it's not a collection of resources. Otherwise, it checks for a passed block, if true, then it yield each page to said block, if not, it collects all response in a single array then returns it.

Closes #22998

See merge request !6703
parents 8a96910c 333c02a8
......@@ -102,9 +102,19 @@ module Gitlab
def request(method, *args, &block)
sleep rate_limit_sleep_time if rate_limit_exceed?
data = api.send(method, *args, &block)
yield data
data = api.send(method, *args)
return data unless data.is_a?(Array)
if block_given?
yield data
each_response_page(&block)
else
each_response_page { |page| data.concat(page) }
data
end
end
def each_response_page
last_response = api.last_response
while last_response.rels[:next]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment