summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-07-14 15:18:50 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-07-14 15:18:50 +0000
commit0618ad12e2b50dd01ec1c5ce440345cb64e26133 (patch)
tree4a72bc4f5477f22557a9d6f47e1e5af5abcea5e0 /app/services
parent78f7080e8ba4f1c8af80a441f947532fa236312c (diff)
parentbfdd34c52a085cec25b439ed41a3c07901bb9708 (diff)
downloadgitlab-ce-0618ad12e2b50dd01ec1c5ce440345cb64e26133.tar.gz
Merge branch 'fix/gb/recover-from-renaming-project-with-container-images' into 'master'
Recover from renaming project that has container images Closes #23019 See merge request !12840
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/update_service.rb47
1 files changed, 33 insertions, 14 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb
index 55d9cb13ae4..30ca95eef7a 100644
--- a/app/services/projects/update_service.rb
+++ b/app/services/projects/update_service.rb
@@ -1,22 +1,16 @@
module Projects
class UpdateService < BaseService
def execute
- # check that user is allowed to set specified visibility_level
- new_visibility = params[:visibility_level]
-
- if new_visibility && new_visibility.to_i != project.visibility_level
- unless can?(current_user, :change_visibility_level, project) &&
- Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
-
- deny_visibility_level(project, new_visibility)
- return error('Visibility level unallowed')
- end
+ unless visibility_level_allowed?
+ return error('New visibility level not allowed!')
end
- new_branch = params[:default_branch]
+ if project.has_container_registry_tags?
+ return error('Cannot rename project because it contains container registry tags!')
+ end
- if project.repository.exists? && new_branch && new_branch != project.default_branch
- project.change_head(new_branch)
+ if changing_default_branch?
+ project.change_head(params[:default_branch])
end
if project.update_attributes(params.except(:default_branch))
@@ -28,8 +22,33 @@ module Projects
success
else
- error('Project could not be updated')
+ error('Project could not be updated!')
end
end
+
+ private
+
+ def visibility_level_allowed?
+ # check that user is allowed to set specified visibility_level
+ new_visibility = params[:visibility_level]
+
+ if new_visibility && new_visibility.to_i != project.visibility_level
+ unless can?(current_user, :change_visibility_level, project) &&
+ Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
+
+ deny_visibility_level(project, new_visibility)
+ return false
+ end
+ end
+
+ true
+ end
+
+ def changing_default_branch?
+ new_branch = params[:default_branch]
+
+ project.repository.exists? &&
+ new_branch && new_branch != project.default_branch
+ end
end
end