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

45 lines
1.5 KiB
Ruby
Raw Normal View History

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
2017-08-17 22:00:37 +05:30
ImportTable = [
2018-03-17 18:26:18 +05:30
ImportSource.new('github', 'GitHub', Gitlab::GithubImport::ParallelImporter),
2017-08-17 22:00:37 +05:30
ImportSource.new('bitbucket', 'Bitbucket', Gitlab::BitbucketImport::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),
2018-03-17 18:26:18 +05:30
ImportSource.new('gitea', 'Gitea', Gitlab::LegacyGithubImport::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
@options ||= Hash[ImportTable.map { |importer| [importer.title, importer.name] }]
end
2015-09-25 12:07:36 +05:30
def values
2017-08-17 22:00:37 +05:30
@values ||= ImportTable.map(&:name)
2015-09-25 12:07:36 +05:30
end
2017-08-17 22:00:37 +05:30
def importer_names
@importer_names ||= ImportTable.select(&:importer).map(&:name)
end
def importer(name)
ImportTable.find { |import_source| import_source.name == name }.importer
end
def title(name)
options.key(name)
2015-09-25 12:07:36 +05:30
end
end
end
end