diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-01 16:37:58 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-09 11:22:38 -0300 |
commit | 02761638f13a9c234794e9d6161e4bf766eab5f0 (patch) | |
tree | e4617066e405a8b6a01fff3a3ae694b292051a03 /lib | |
parent | 4bdcbc85987a03f21bc326905b581239f74f8b04 (diff) | |
download | gitlab-ce-02761638f13a9c234794e9d6161e4bf766eab5f0.tar.gz |
Avoid conflict with admin labels when importing GitHub labels
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/github_import/label_formatter.rb | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index 4fdc2f46be0..0388c58f811 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -133,8 +133,7 @@ module Gitlab if issue.labels.count > 0 label_ids = issue.labels - .map { |raw| LabelFormatter.new(project, raw).attributes } - .map { |attrs| Label.find_by(attrs).try(:id) } + .map { |attrs| project.labels.find_by(title: attrs.name).try(:id) } .compact issuable.update_attribute(:label_ids, label_ids) diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb index 9f18244e7d7..2cad7fca88e 100644 --- a/lib/gitlab/github_import/label_formatter.rb +++ b/lib/gitlab/github_import/label_formatter.rb @@ -13,6 +13,12 @@ module Gitlab Label end + def create! + project.labels.find_or_create_by!(title: title) do |label| + label.color = color + end + end + private def color |