2018-10-22 03:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-12 02:13:20 -04:00
|
|
|
# Gitlab::ImportSources module
|
|
|
|
#
|
|
|
|
# Define import sources that can be used
|
|
|
|
# during the creation of new project
|
|
|
|
#
|
|
|
|
module Gitlab
|
|
|
|
module ImportSources
|
2016-12-16 03:15:30 -05:00
|
|
|
ImportSource = Struct.new(:name, :title, :importer)
|
|
|
|
|
2018-01-03 03:31:32 -05:00
|
|
|
# We exclude `bare_repository` here as it has no import class associated
|
2018-12-09 12:45:48 -05:00
|
|
|
IMPORT_TABLE = [
|
2022-05-31 08:09:12 -04:00
|
|
|
ImportSource.new('github', 'GitHub', Gitlab::GithubImport::ParallelImporter),
|
|
|
|
ImportSource.new('bitbucket', 'Bitbucket Cloud', Gitlab::BitbucketImport::Importer),
|
|
|
|
ImportSource.new('bitbucket_server', 'Bitbucket Server', Gitlab::BitbucketServerImport::Importer),
|
|
|
|
ImportSource.new('gitlab', 'GitLab.com', Gitlab::GitlabImport::Importer),
|
|
|
|
ImportSource.new('google_code', 'Google Code', nil),
|
|
|
|
ImportSource.new('fogbugz', 'FogBugz', Gitlab::FogbugzImport::Importer),
|
|
|
|
ImportSource.new('git', 'Repository by URL', nil),
|
|
|
|
ImportSource.new('gitlab_project', 'GitLab export', Gitlab::ImportExport::Importer),
|
|
|
|
ImportSource.new('gitea', 'Gitea', Gitlab::LegacyGithubImport::Importer),
|
|
|
|
ImportSource.new('manifest', 'Manifest file', nil),
|
|
|
|
ImportSource.new('phabricator', 'Phabricator', Gitlab::PhabricatorImport::Importer)
|
2016-12-16 03:15:30 -05:00
|
|
|
].freeze
|
|
|
|
|
2015-08-12 02:13:20 -04:00
|
|
|
class << self
|
2021-05-11 17:10:21 -04:00
|
|
|
prepend_mod_with('Gitlab::ImportSources') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2016-12-16 03:15:30 -05:00
|
|
|
def options
|
2021-04-05 14:09:15 -04:00
|
|
|
import_table.to_h { |importer| [importer.title, importer.name] }
|
2016-12-16 03:15:30 -05:00
|
|
|
end
|
|
|
|
|
2015-08-12 02:13:20 -04:00
|
|
|
def values
|
2018-07-20 19:25:10 -04:00
|
|
|
import_table.map(&:name)
|
2015-08-12 02:13:20 -04:00
|
|
|
end
|
|
|
|
|
2016-12-16 03:15:30 -05:00
|
|
|
def importer_names
|
2018-07-20 19:25:10 -04:00
|
|
|
import_table.select(&:importer).map(&:name)
|
2016-12-16 03:15:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def importer(name)
|
2018-07-20 19:25:10 -04:00
|
|
|
import_table.find { |import_source| import_source.name == name }.importer
|
2016-12-16 03:15:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def title(name)
|
|
|
|
options.key(name)
|
2015-08-12 02:13:20 -04:00
|
|
|
end
|
2018-07-20 19:25:10 -04:00
|
|
|
|
|
|
|
def import_table
|
2018-12-09 12:45:48 -05:00
|
|
|
IMPORT_TABLE
|
2018-07-20 19:25:10 -04:00
|
|
|
end
|
2015-08-12 02:13:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|