update_context.rb 685 Bytes
Newer Older
1
2
3
module Projects
  class UpdateContext < BaseContext
    def execute(role = :default)
4
      params[:project].delete(:namespace_id)
5
6
7
8
9
      # 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

10
11
      new_branch = params[:project].delete(:default_branch)

12
      if project.repository.exists? && new_branch != project.default_branch
13
        project.change_head(new_branch)
14
15
      end

16
17
18
19
      project.update_attributes(params[:project], as: role)
    end
  end
end