diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-04-19 20:45:49 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-04-24 16:17:52 -0300 |
commit | a7cb336e55a56797919dddeef3978997962127d3 (patch) | |
tree | fea0a5f0553c1ab1379d3cacee6407754765751c /lib/github/import.rb | |
parent | 181445307cbb4a8cb2904a3b969bc39568d133d5 (diff) | |
download | gitlab-ce-a7cb336e55a56797919dddeef3978997962127d3.tar.gz |
Use while instead of loop/break
Diffstat (limited to 'lib/github/import.rb')
-rw-r--r-- | lib/github/import.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/github/import.rb b/lib/github/import.rb index 0552320a474..e9632d3ee11 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -54,14 +54,12 @@ module Github # Fetch labels url = "/repos/#{owner}/#{repo}/labels" - loop do + while url response = Github::Client.new(options).get(url) response.body.each do |raw| begin label = Github::Representation::Label.new(raw) - - # TODO: we should take group labels in account next if project.labels.where(title: label.title).exists? project.labels.create!(title: label.title, color: label.color) @@ -70,7 +68,7 @@ module Github end end - break unless url = response.rels[:next] + url = response.rels[:next] end # Cache labels @@ -82,7 +80,7 @@ module Github # Fetch milestones url = "/repos/#{owner}/#{repo}/milestones" - loop do + while url response = Github::Client.new(options).get(url, state: :all) response.body.each do |raw| @@ -104,13 +102,13 @@ module Github end end - break unless url = response.rels[:next] + url = response.rels[:next] end # Fetch pull requests url = "/repos/#{owner}/#{repo}/pulls" - loop do + while url response = Github::Client.new(options).get(url, state: :all, sort: :created, direction: :asc) response.body.each do |raw| @@ -156,13 +154,13 @@ module Github end end - break unless url = response.rels[:next] + url = response.rels[:next] end # Fetch issues url = "/repos/#{owner}/#{repo}/issues" - loop do + while url response = Github::Client.new(options).get(url, state: :all, sort: :created, direction: :asc) response.body.each do |raw| @@ -207,7 +205,7 @@ module Github end end - break unless url = response.rels[:next] + url = response.rels[:next] end repository.expire_content_cache @@ -218,7 +216,7 @@ module Github private def fetch_comments(noteable, type, url) - loop do + while url comments = Github::Client.new(options).get(url) ActiveRecord::Base.no_touching do @@ -244,7 +242,7 @@ module Github end end - break unless url = comments.rels[:next] + url = comments.rels[:next] end end |