Commit eaa0303b authored by Ahmad Sherif's avatar Ahmad Sherif

Cache imported GH labels no matter what

parent 6a9fb20f
...@@ -52,15 +52,14 @@ module Gitlab ...@@ -52,15 +52,14 @@ module Gitlab
fetch_resources(:labels, repo, per_page: 100) do |labels| fetch_resources(:labels, repo, per_page: 100) do |labels|
labels.each do |raw| labels.each do |raw|
begin begin
label = LabelFormatter.new(project, raw).create! LabelFormatter.new(project, raw).create!
@labels[label.title] = label.id
rescue => e rescue => e
errors << { type: :label, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message } errors << { type: :label, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message }
end end
end end
end end
ensure_labels_are_cached cache_labels!
end end
def import_milestones def import_milestones
...@@ -236,9 +235,7 @@ module Gitlab ...@@ -236,9 +235,7 @@ module Gitlab
end end
end end
def ensure_labels_are_cached def cache_labels!
return unless @labels.empty?
project.labels.select(:id, :title).find_each do |label| project.labels.select(:id, :title).find_each do |label|
@labels[label.title] = label.id @labels[label.title] = label.id
end end
......
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