From 28bb65f3637ae16c98f374248e3ffa5f26983443 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 16 Dec 2013 19:34:56 +0200 Subject: [PATCH] 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: Dmitriy Zaporozhets --- app/contexts/projects/update_context.rb | 8 +------- app/models/project.rb | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/contexts/projects/update_context.rb b/app/contexts/projects/update_context.rb index 55a4a6abecb..ed0d451a31a 100644 --- a/app/contexts/projects/update_context.rb +++ b/app/contexts/projects/update_context.rb @@ -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) diff --git a/app/models/project.rb b/app/models/project.rb index 506f34ca6b6..5f0303dfb06 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 -- GitLab