Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-06 16:29:08 +0300
committerRémy Coutable <remy@rymai.me>2016-10-06 16:29:08 +0300
commit0a7678b58ad6f17e78086c2e320647c3a4dd461f (patch)
treeaa4adeac946be56c7f28f7d4942af5e0e1e10d76
parent8a96910cf5b361295c52b1c3ee89fc7435ad5927 (diff)
parent333c02a8c822dfab1b98c55db8fb8daa4c53bd51 (diff)
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
-rw-r--r--lib/gitlab/github_import/client.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index e33ac61f5ae..7f424b74efb 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -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]