summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-03 16:29:11 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-03 16:29:11 +0200
commita9b221d91a5529c514615b640cdbbaf6b99bf790 (patch)
tree079156f2e7ac883f333a588435d8edf8ee63ad69 /app/models/project.rb
parentfc5eb3157082d923b80596485b302504ce0671ea (diff)
downloadgitlab-ce-a9b221d91a5529c514615b640cdbbaf6b99bf790.tar.gz
Refine method for checking project registry tags
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb20
1 files changed, 20 insertions, 0 deletions
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