2013-01-17 10:35:57 -05:00
|
|
|
module Projects
|
2014-01-16 12:03:42 -05:00
|
|
|
class UpdateService < BaseService
|
2013-01-17 10:35:57 -05:00
|
|
|
def execute(role = :default)
|
2013-03-25 04:48:30 -04:00
|
|
|
params[:project].delete(:namespace_id)
|
2013-11-06 10:13:21 -05:00
|
|
|
# check that user is allowed to set specified visibility_level
|
|
|
|
unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:project][:visibility_level])
|
|
|
|
params[:project].delete(:visibility_level)
|
|
|
|
end
|
|
|
|
|
2013-11-06 11:45:39 -05:00
|
|
|
new_branch = params[:project].delete(:default_branch)
|
|
|
|
|
2013-12-23 06:19:13 -05:00
|
|
|
if project.repository.exists? && new_branch && new_branch != project.default_branch
|
2013-12-16 12:34:56 -05:00
|
|
|
project.change_head(new_branch)
|
2013-11-06 11:45:39 -05:00
|
|
|
end
|
|
|
|
|
2013-01-17 10:35:57 -05:00
|
|
|
project.update_attributes(params[:project], as: role)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|