diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-04 18:48:41 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-04 18:48:41 +0000 |
commit | 8d0d8b91e46573e8fe46dc712e84c65708a00b97 (patch) | |
tree | 5691f8566fa7f98fe1a14b76c2779a6fe940b5fd | |
parent | 86b8fb4e7f376bdb70faf8ce99f34b6ec0fc8dc1 (diff) | |
parent | eaa0303b3d2f1480222c94a85d356b055f7100b3 (diff) | |
download | gitlab-ce-8d0d8b91e46573e8fe46dc712e84c65708a00b97.tar.gz |
Merge branch 'fix/gh-imported-labels-are-not-applied-correctly' into 'master'
Fix applying GitHub-imported labels when importing job is interrupted
Closes #24075
See merge request !7245
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9411cc62003..c055d1f384e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ entry. - In all filterable drop downs, put input field in focus only after load is complete (Ido @leibo) - Improve search query parameter naming in /admin/users !7115 (YarNayar) - Fix table pagination to be responsive +- Fix applying GitHub-imported labels when importing job is interrupted - Allow to search for user by secondary email address in the admin interface(/admin/users) !7115 (YarNayar) - Updated commit SHA styling on the branches page. diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index ecc28799737..90cf38a8513 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -52,13 +52,14 @@ module Gitlab fetch_resources(:labels, repo, per_page: 100) do |labels| labels.each do |raw| begin - label = LabelFormatter.new(project, raw).create! - @labels[label.title] = label.id + LabelFormatter.new(project, raw).create! rescue => e errors << { type: :label, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message } end end end + + cache_labels! end def import_milestones @@ -234,6 +235,12 @@ module Gitlab end end + def cache_labels! + project.labels.select(:id, :title).find_each do |label| + @labels[label.title] = label.id + end + end + def fetch_resources(resource_type, *opts) return if imported?(resource_type) |