Read about our upcoming Code of Conduct on this issue

update_context.rb 796 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
12
13
14
15
16
17
18
19
      new_branch = params[:project].delete(:default_branch)

      if project.repository.exists? && new_branch != project.repository.root_ref
        GitlabShellWorker.perform_async(
          :update_repository_head,
          project.path_with_namespace,
          new_branch
        )
      end

20
21
22
23
      project.update_attributes(params[:project], as: role)
    end
  end
end