debian-mirror-gitlab/lib/gitlab/import_sources.rb

54 lines
1.9 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2015-09-25 12:07:36 +05:30
# Gitlab::ImportSources module
#
# Define import sources that can be used
# during the creation of new project
#
module Gitlab
module ImportSources
2017-08-17 22:00:37 +05:30
ImportSource = Struct.new(:name, :title, :importer)
2018-03-17 18:26:18 +05:30
# We exclude `bare_repository` here as it has no import class associated
2019-02-15 15:39:39 +05:30
IMPORT_TABLE = [
2018-11-18 11:00:15 +05:30
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),
2019-09-04 21:01:54 +05:30
ImportSource.new('manifest', 'Manifest file', nil),
ImportSource.new('phabricator', 'Phabricator', Gitlab::PhabricatorImport::Importer)
2017-08-17 22:00:37 +05:30
].freeze
2015-09-25 12:07:36 +05:30
class << self
2017-08-17 22:00:37 +05:30
def options
2018-11-18 11:00:15 +05:30
Hash[import_table.map { |importer| [importer.title, importer.name] }]
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
def values
2018-11-18 11:00:15 +05:30
import_table.map(&:name)
2015-09-25 12:07:36 +05:30
end
2017-08-17 22:00:37 +05:30
def importer_names
2018-11-18 11:00:15 +05:30
import_table.select(&:importer).map(&:name)
2017-08-17 22:00:37 +05:30
end
def importer(name)
2018-11-18 11:00:15 +05:30
import_table.find { |import_source| import_source.name == name }.importer
2017-08-17 22:00:37 +05:30
end
def title(name)
options.key(name)
2015-09-25 12:07:36 +05:30
end
2018-11-18 11:00:15 +05:30
def import_table
2019-02-15 15:39:39 +05:30
IMPORT_TABLE
2018-11-18 11:00:15 +05:30
end
2015-09-25 12:07:36 +05:30
end
end
end