summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-05-18 11:22:28 -0500
committerKamil Trzcinski <ayufan@ayufan.eu>2016-05-18 11:22:28 -0500
commit2f1cb7ce0439de003e92c55a27c6a8db7f0f1803 (patch)
tree95a458450b64b8b373f1bf5cc80a33a680cc2a3d
parent24145592e804ffbe58a38b15095808919337d545 (diff)
downloadgitlab-ce-2f1cb7ce0439de003e92c55a27c6a8db7f0f1803.tar.gz
Improve code design
-rw-r--r--app/controllers/projects/container_registry_controller.rb6
-rw-r--r--app/models/project.rb8
2 files changed, 9 insertions, 5 deletions
diff --git a/app/controllers/projects/container_registry_controller.rb b/app/controllers/projects/container_registry_controller.rb
index 8ed5a8ff6fd..3648f8894a6 100644
--- a/app/controllers/projects/container_registry_controller.rb
+++ b/app/controllers/projects/container_registry_controller.rb
@@ -8,10 +8,12 @@ class Projects::ContainerRegistryController < Projects::ApplicationController
end
def destroy
+ url = namespace_project_container_registry_index_path(project.namespace, project)
+
if tag.delete
- redirect_to namespace_project_container_registry_index_path(project.namespace, project)
+ redirect_to url
else
- redirect_to namespace_project_container_registry_index_path(project.namespace, project), alert: 'Failed to remove tag'
+ redirect_to url, alert: 'Failed to remove tag'
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 09a214da043..321a1932a20 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -331,6 +331,8 @@ class Project < ActiveRecord::Base
end
def container_registry_repository
+ return unless Gitlab.config.registry.enabled
+
@container_registry_repository ||= begin
token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace)
url = Gitlab.config.registry.api_url
@@ -347,9 +349,9 @@ class Project < ActiveRecord::Base
end
def has_container_registry_tags?
- if Gitlab.config.registry.enabled
- container_registry_repository.tags.any?
- end
+ return unless container_registry_repository
+
+ container_registry_repository.tags.any?
end
def commit(id = 'HEAD')