summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/label_formatter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/github_import/label_formatter.rb')
-rw-r--r--lib/gitlab/github_import/label_formatter.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb
index 2cad7fca88e..942dfb3312b 100644
--- a/lib/gitlab/github_import/label_formatter.rb
+++ b/lib/gitlab/github_import/label_formatter.rb
@@ -14,9 +14,13 @@ module Gitlab
end
def create!
- project.labels.find_or_create_by!(title: title) do |label|
- label.color = color
- end
+ params = attributes.except(:project)
+ service = ::Labels::FindOrCreateService.new(project.owner, project, params)
+ label = service.execute
+
+ raise ActiveRecord::RecordInvalid.new(label) unless label.persisted?
+
+ label
end
private