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]
|
|
|
|
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 project
|
|
|
|
end
|
2013-11-06 15:13:21 +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
|