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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.8 KiB
Ruby
Raw Permalink 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)
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),
2023-06-20 00:43:36 +05:30
ImportSource.new('bitbucket_server', 'Bitbucket Server', Gitlab::BitbucketServerImport::ParallelImporter),
2022-07-23 23:45:48 +05:30
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),
2023-07-09 08:55:56 +05:30
ImportSource.new('manifest', 'Manifest file', nil)
2017-08-17 22:00:37 +05:30
].freeze
2015-09-25 12:07:36 +05:30
2023-06-20 00:43:36 +05:30
LEGACY_IMPORT_TABLE = IMPORT_TABLE.deep_dup
LEGACY_IMPORT_TABLE[2].importer = Gitlab::BitbucketServerImport::Importer
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
2023-07-09 08:55:56 +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
2023-06-20 00:43:36 +05:30
return IMPORT_TABLE if Feature.enabled?(:bitbucket_server_parallel_importer)
LEGACY_IMPORT_TABLE
2018-11-18 11:00:15 +05:30
end
2015-09-25 12:07:36 +05:30
end
end
end