Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 14:10:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 14:10:13 +0300
commit0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch)
tree7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/services/bulk_imports
parent72123183a20411a36d607d70b12d57c484394c8e (diff)
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/services/bulk_imports')
-rw-r--r--app/services/bulk_imports/create_pipeline_trackers_service.rb68
-rw-r--r--app/services/bulk_imports/file_export_service.rb4
-rw-r--r--app/services/bulk_imports/lfs_objects_export_service.rb2
-rw-r--r--app/services/bulk_imports/repository_bundle_export_service.rb23
4 files changed, 97 insertions, 0 deletions
diff --git a/app/services/bulk_imports/create_pipeline_trackers_service.rb b/app/services/bulk_imports/create_pipeline_trackers_service.rb
new file mode 100644
index 00000000000..5c9c68e62b5
--- /dev/null
+++ b/app/services/bulk_imports/create_pipeline_trackers_service.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+module BulkImports
+ class CreatePipelineTrackersService
+ def initialize(entity)
+ @entity = entity
+ end
+
+ def execute!
+ entity.class.transaction do
+ entity.pipelines.each do |pipeline|
+ status = skip_pipeline?(pipeline) ? -2 : 0
+
+ entity.trackers.create!(
+ stage: pipeline[:stage],
+ pipeline_name: pipeline[:pipeline],
+ status: status
+ )
+ end
+ end
+ end
+
+ private
+
+ attr_reader :entity
+
+ def skip_pipeline?(pipeline)
+ return false unless source_version.valid?
+
+ minimum_version, maximum_version = pipeline.values_at(:minimum_source_version, :maximum_source_version)
+
+ if minimum_version && non_patch_source_version < Gitlab::VersionInfo.parse(minimum_version)
+ log_skipped_pipeline(pipeline, minimum_version, maximum_version)
+ return true
+ end
+
+ if maximum_version && non_patch_source_version > Gitlab::VersionInfo.parse(maximum_version)
+ log_skipped_pipeline(pipeline, minimum_version, maximum_version)
+ return true
+ end
+
+ false
+ end
+
+ def source_version
+ @source_version ||= entity.bulk_import.source_version_info
+ end
+
+ def non_patch_source_version
+ Gitlab::VersionInfo.new(source_version.major, source_version.minor, 0)
+ end
+
+ def log_skipped_pipeline(pipeline, minimum_version, maximum_version)
+ logger.info(
+ message: 'Pipeline skipped as source instance version not compatible with pipeline',
+ entity_id: entity.id,
+ pipeline_name: pipeline[:pipeline],
+ minimum_source_version: minimum_version,
+ maximum_source_version: maximum_version,
+ source_version: source_version.to_s
+ )
+ end
+
+ def logger
+ @logger ||= Gitlab::Import::Logger.build
+ end
+ end
+end
diff --git a/app/services/bulk_imports/file_export_service.rb b/app/services/bulk_imports/file_export_service.rb
index a9d06d84277..b2d114368a1 100644
--- a/app/services/bulk_imports/file_export_service.rb
+++ b/app/services/bulk_imports/file_export_service.rb
@@ -30,6 +30,10 @@ module BulkImports
UploadsExportService.new(portable, export_path)
when FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION
LfsObjectsExportService.new(portable, export_path)
+ when FileTransfer::ProjectConfig::REPOSITORY_BUNDLE_RELATION
+ RepositoryBundleExportService.new(portable.repository, export_path, relation)
+ when FileTransfer::ProjectConfig::DESIGN_BUNDLE_RELATION
+ RepositoryBundleExportService.new(portable.design_repository, export_path, relation)
else
raise BulkImports::Error, 'Unsupported relation export type'
end
diff --git a/app/services/bulk_imports/lfs_objects_export_service.rb b/app/services/bulk_imports/lfs_objects_export_service.rb
index fa606e4e5a3..1f745201c8a 100644
--- a/app/services/bulk_imports/lfs_objects_export_service.rb
+++ b/app/services/bulk_imports/lfs_objects_export_service.rb
@@ -32,6 +32,8 @@ module BulkImports
destination_filepath = File.join(export_path, lfs_object.oid)
if lfs_object.local_store?
+ return unless File.exist?(lfs_object.file.path)
+
copy_files(lfs_object.file.path, destination_filepath)
else
download(lfs_object.file.url, destination_filepath)
diff --git a/app/services/bulk_imports/repository_bundle_export_service.rb b/app/services/bulk_imports/repository_bundle_export_service.rb
new file mode 100644
index 00000000000..31a2ed6d1af
--- /dev/null
+++ b/app/services/bulk_imports/repository_bundle_export_service.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module BulkImports
+ class RepositoryBundleExportService
+ def initialize(repository, export_path, export_filename)
+ @repository = repository
+ @export_path = export_path
+ @export_filename = export_filename
+ end
+
+ def execute
+ repository.bundle_to_disk(bundle_filepath) if repository.exists?
+ end
+
+ private
+
+ attr_reader :repository, :export_path, :export_filename
+
+ def bundle_filepath
+ File.join(export_path, "#{export_filename}.bundle")
+ end
+ end
+end