debian-mirror-gitlab/lib/gitlab/legacy_github_import/label_formatter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
733 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
module Gitlab
2018-03-17 18:26:18 +05:30
module LegacyGithubImport
2016-06-02 11:05:42 +05:30
class LabelFormatter < BaseFormatter
def attributes
{
project: project,
title: title,
color: color
}
end
2016-11-03 12:29:30 +05:30
def project_association
:labels
end
2016-09-29 09:46:39 +05:30
def create!
2016-11-03 12:29:30 +05:30
params = attributes.except(:project)
service = ::Labels::FindOrCreateService.new(nil, project, params)
label = service.execute(skip_authorization: true)
2021-06-08 01:23:25 +05:30
raise ActiveRecord::RecordInvalid, label unless label.persisted?
2016-11-03 12:29:30 +05:30
label
2016-09-29 09:46:39 +05:30
end
2016-06-02 11:05:42 +05:30
private
def color
"##{raw_data.color}"
end
def title
raw_data.name
end
end
end
end