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

56 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 = [
2022-07-23 23:45:48 +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', 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)
2017-08-17 22:00:37 +05:30
].freeze
2015-09-25 12:07:36 +05:30
class << self
2021-06-08 01:23:25 +05:30
prepend_mod_with('Gitlab::ImportSources') # rubocop: disable Cop/InjectEnterpriseEditionModule
2019-12-04 20:38:33 +05:30
2017-08-17 22:00:37 +05:30
def options
2021-04-29 21:17:54 +05:30
import_table.to_h { |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