2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
module Gitlab
|
2018-03-17 18:26:18 +05:30
|
|
|
module LegacyGithubImport
|
2016-01-14 18:37:52 +05:30
|
|
|
class BaseFormatter
|
2017-08-17 22:00:37 +05:30
|
|
|
attr_reader :client, :formatter, :project, :raw_data
|
2016-01-14 18:37:52 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def initialize(project, raw_data, client = nil)
|
2016-01-14 18:37:52 +05:30
|
|
|
@project = project
|
|
|
|
@raw_data = raw_data
|
2017-08-17 22:00:37 +05:30
|
|
|
@client = client
|
2016-01-14 18:37:52 +05:30
|
|
|
@formatter = Gitlab::ImportFormatter.new
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-06-16 23:09:34 +05:30
|
|
|
def create!
|
2018-03-17 18:26:18 +05:30
|
|
|
association = project.public_send(project_association) # rubocop:disable GitlabSecurity/PublicSend
|
|
|
|
|
|
|
|
association.find_or_create_by!(find_condition) do |record|
|
2016-11-03 12:29:30 +05:30
|
|
|
record.attributes = attributes
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def url
|
|
|
|
raw_data.url || ''
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|