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 = [
|
2018-08-02 17:43:32 -04:00
|
|
|
ImportSource.new('github', 'GitHub', Gitlab::GithubImport::ParallelImporter),
|
|
|
|
ImportSource.new('bitbucket', 'Bitbucket Cloud', Gitlab::BitbucketImport::Importer),
|
2018-06-25 16:06:10 -04:00
|
|
|
ImportSource.new('bitbucket_server', 'Bitbucket Server', Gitlab::BitbucketServerImport::Importer),
|
2018-08-02 17:43:32 -04:00
|
|
|
ImportSource.new('gitlab', 'GitLab.com', Gitlab::GitlabImport::Importer),
|
|
|
|
ImportSource.new('google_code', 'Google Code', Gitlab::GoogleCodeImport::Importer),
|
|
|
|
ImportSource.new('fogbugz', 'FogBugz', Gitlab::FogbugzImport::Importer),
|
|
|
|
ImportSource.new('git', 'Repo by URL', nil),
|
|
|
|
ImportSource.new('gitlab_project', 'GitLab export', Gitlab::ImportExport::Importer),
|
|
|
|
ImportSource.new('gitea', 'Gitea', Gitlab::LegacyGithubImport::Importer),
|
2019-04-23 10:27:01 -04:00
|
|
|
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
|
2016-12-16 03:15:30 -05:00
|
|
|
def options
|
2018-07-20 19:25:10 -04:00
|
|
|
Hash[import_table.map { |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
|