From a9b221d91a5529c514615b640cdbbaf6b99bf790 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 3 Apr 2017 16:29:11 +0200 Subject: Refine method for checking project registry tags --- app/models/project.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/models/project.rb') diff --git a/app/models/project.rb b/app/models/project.rb index 649d0e100c3..0adec807f34 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -406,6 +406,11 @@ class Project < ActiveRecord::Base end end + def has_container_registry_tags? + container_repositories.to_a.any?(&:has_tags?) || + has_root_container_repository_tags? + end + def commit(ref = 'HEAD') repository.commit(ref) end @@ -1373,4 +1378,19 @@ class Project < ActiveRecord::Base Project.unscoped.where(pending_delete: true).find_by_full_path(path_with_namespace) end + + ## + # This method is here because of support for legacy container repository + # which has exactly the same path like project does, but which might not be + # persisted in `container_repositories` table. + # + def has_root_container_repository_tags? + return false unless Gitlab.config.registry.enabled + + ContainerRegistry::Path.new(self.full_path).tap do |path| + ContainerRepository.build_from_path(path).tap do |repository| + return repository.has_tags? + end + end + end end -- cgit v1.2.1