Update repository head successively during project update

It prevents situation when async worker slowly updates HEAD and we show
old branch as repository HEAD in project settings
Signed-off-by: NDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
上级 99490159
......@@ -10,13 +10,7 @@ module Projects
new_branch = params[:project].delete(:default_branch)
if project.repository.exists? && new_branch != project.default_branch
GitlabShellWorker.perform_async(
:update_repository_head,
project.path_with_namespace,
new_branch
)
project.reload_default_branch
project.change_head(new_branch)
end
project.update_attributes(params[:project], as: role)
......
......@@ -472,4 +472,9 @@ class Project < ActiveRecord::Base
def visibility_level_field
visibility_level
end
def change_head(branch)
gitlab_shell.update_repository_head(self.path_with_namespace, branch)
reload_default_branch
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册