gitlab-org--gitlab-foss/lib/gitlab/import_sources.rb

54 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
# Gitlab::ImportSources module
#
# Define import sources that can be used
# during the creation of new project
#
module Gitlab
module ImportSources
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 = [
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', 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),
ImportSource.new('manifest', 'Manifest file', nil),
ImportSource.new('phabricator', 'Phabricator', Gitlab::PhabricatorImport::Importer)
].freeze
class << self
def options
2018-07-20 19:25:10 -04:00
Hash[import_table.map { |importer| [importer.title, importer.name] }]
end
def values
2018-07-20 19:25:10 -04:00
import_table.map(&:name)
end
def importer_names
2018-07-20 19:25:10 -04:00
import_table.select(&:importer).map(&:name)
end
def importer(name)
2018-07-20 19:25:10 -04:00
import_table.find { |import_source| import_source.name == name }.importer
end
def title(name)
options.key(name)
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
end
end
end