2013-01-17 15:35:57 +00:00
|
|
|
module Projects
|
2015-03-07 19:47:06 +00:00
|
|
|
class UpdateService < BaseService
|
2014-06-26 11:30:07 +00:00
|
|
|
def execute
|
2013-11-06 15:13:21 +00:00
|
|
|
# check that user is allowed to set specified visibility_level
|
2015-03-07 18:23:43 +00:00
|
|
|
new_visibility = params[:visibility_level]
|
2016-07-26 03:27:46 +00:00
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
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)
|
2016-07-06 13:26:59 +00:00
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
deny_visibility_level(project, new_visibility)
|
|
|
|
return project
|
2015-03-07 18:23:43 +00:00
|
|
|
end
|
2015-11-03 17:23:48 +00:00
|
|
|
end
|
|
|
|
|
2014-06-26 20:24:17 +00:00
|
|
|
new_branch = params[:default_branch]
|
2013-11-06 16:45:39 +00:00
|
|
|
|
2013-12-23 11:19:13 +00:00
|
|
|
if project.repository.exists? && new_branch && new_branch != project.default_branch
|
2013-12-16 17:34:56 +00:00
|
|
|
project.change_head(new_branch)
|
2013-11-06 16:45:39 +00:00
|
|
|
end
|
|
|
|
|
2014-06-26 20:24:17 +00:00
|
|
|
if project.update_attributes(params.except(:default_branch))
|
2014-06-17 18:53:26 +00:00
|
|
|
if project.previous_changes.include?('path')
|
|
|
|
project.rename_repo
|
|
|
|
end
|
|
|
|
end
|
2013-01-17 15:35:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|