update_context.rb 602 Bytes
Newer Older
1
2
3
module Projects
  class UpdateContext < BaseContext
    def execute(role = :default)
4
      params[:project].delete(:namespace_id)
5
      params[:project].delete(:public) unless can?(current_user, :change_public_mode, project)
6
7
8
9
10
11
12
13
14
15
      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

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