2013-01-17 10:35:57 -05:00
|
|
|
module Projects
|
2014-01-16 12:03:42 -05:00
|
|
|
class UpdateService < BaseService
|
2014-06-26 07:30:07 -04:00
|
|
|
def execute
|
2013-11-06 10:13:21 -05:00
|
|
|
# check that user is allowed to set specified visibility_level
|
2014-06-26 07:30:07 -04:00
|
|
|
unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
|
2014-06-26 16:24:17 -04:00
|
|
|
params[:visibility_level] = project.visibility_level
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
2014-06-26 16:24:17 -04:00
|
|
|
new_branch = params[:default_branch]
|
2013-11-06 11:45:39 -05:00
|
|
|
|
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
|
|
|
|
|
2014-06-26 16:24:17 -04:00
|
|
|
if project.update_attributes(params.except(:default_branch))
|
2014-06-17 14:53:26 -04:00
|
|
|
if project.previous_changes.include?('path')
|
|
|
|
project.rename_repo
|
|
|
|
end
|
|
|
|
end
|
2013-01-17 10:35:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|