summaryrefslogtreecommitdiff
path: root/lib/container_registry
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 13:45:54 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 13:45:54 +0200
commit003a51d17aea6af92953f7207e2b39a5cb6db8de (patch)
tree37204d4149b2c63fd0daea365e4a358b820a7882 /lib/container_registry
parent031122eb54390b4ed792289237ecfb156ec69002 (diff)
downloadgitlab-ce-003a51d17aea6af92953f7207e2b39a5cb6db8de.tar.gz
Check container repository exists for a given path
Diffstat (limited to 'lib/container_registry')
-rw-r--r--lib/container_registry/path.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb
index d3f8bf74e14..3a6fde08e8f 100644
--- a/lib/container_registry/path.rb
+++ b/lib/container_registry/path.rb
@@ -33,8 +33,15 @@ module ContainerRegistry
end
end
+ def has_project?
+ repository_project.present?
+ end
+
def has_repository?
- # ContainerRepository.find_by_full_path(@path).present?
+ return false unless has_project?
+
+ repository_project.container_repositories
+ .where(name: repository_name).any?
end
def repository_project
@@ -42,7 +49,7 @@ module ContainerRegistry
end
def repository_name
- return unless repository_project
+ return unless has_project?
@path.remove(%r(^?#{Regexp.escape(repository_project.full_path)}/?))
end