Skip to content
Snippets Groups Projects

Allow transfer of project with registry tags

Merged Adie (she/her) requested to merge 499163-allow-transferring-proj-with-tags into master
All threads resolved!
Files
3
@@ -92,7 +92,7 @@ def transfer(project)
raise TransferError, s_("TransferProject|Project with same name or path in target namespace already exists")
end
verify_if_project_with_tags_can_be_transferred(project) if project.has_container_registry_tags?
verify_if_container_registry_tags_can_be_handled(project)
if !new_namespace_has_same_root?(project) && project.has_namespaced_npm_packages?
raise TransferError, s_("TransferProject|Root namespace can't be updated if the project has NPM packages scoped to the current root level namespace.")
@@ -102,16 +102,27 @@ def transfer(project)
end
# rubocop: enable CodeReuse/ActiveRecord
def verify_if_project_with_tags_can_be_transferred(project)
unless Feature.enabled?(:transfer_project_with_tags, project) &&
ContainerRegistry::GitlabApiClient.supports_gitlab_api?
def verify_if_container_registry_tags_can_be_handled(project)
return unless project.has_container_registry_tags?
raise_error_due_to_tags_if_transfer_is_not_allowed(project)
raise_error_due_to_tags_if_not_in_same_root(project)
raise_error_due_to_tags_if_transfer_dry_run_fails(project)
end
def raise_error_due_to_tags_if_transfer_is_not_allowed(project)
unless Feature.enabled?(:transfer_project_with_tags, project) && ContainerRegistry::GitlabApiClient.supports_gitlab_api?
raise TransferError, s_('TransferProject|Project cannot be transferred, because tags are present in its container registry')
end
end
unless new_namespace_has_same_root?(project)
raise TransferError, s_('TransferProject|Project cannot be transferred to a different top-level namespace, because tags are present in its container registry')
end
def raise_error_due_to_tags_if_not_in_same_root(project)
return if new_namespace_has_same_root?(project)
raise TransferError, s_('TransferProject|Project cannot be transferred to a different top-level namespace, because tags are present in its container registry')
end
def raise_error_due_to_tags_if_transfer_dry_run_fails(project)
dry_run = update_project_namespace_in_registry(project.full_path, new_namespace.full_path, dry_run: true)
return if dry_run == :accepted
Loading