Commit 28bb65f3637ae16c98f374248e3ffa5f26983443
1 parent
99490159
Exists in
master
and in
4 other branches
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 <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
6 additions
and
7 deletions
Show diff stats
app/contexts/projects/update_context.rb
@@ -10,13 +10,7 @@ module Projects | @@ -10,13 +10,7 @@ module Projects | ||
10 | new_branch = params[:project].delete(:default_branch) | 10 | new_branch = params[:project].delete(:default_branch) |
11 | 11 | ||
12 | if project.repository.exists? && new_branch != project.default_branch | 12 | if project.repository.exists? && new_branch != project.default_branch |
13 | - GitlabShellWorker.perform_async( | ||
14 | - :update_repository_head, | ||
15 | - project.path_with_namespace, | ||
16 | - new_branch | ||
17 | - ) | ||
18 | - | ||
19 | - project.reload_default_branch | 13 | + project.change_head(new_branch) |
20 | end | 14 | end |
21 | 15 | ||
22 | project.update_attributes(params[:project], as: role) | 16 | project.update_attributes(params[:project], as: role) |
app/models/project.rb
@@ -472,4 +472,9 @@ class Project < ActiveRecord::Base | @@ -472,4 +472,9 @@ class Project < ActiveRecord::Base | ||
472 | def visibility_level_field | 472 | def visibility_level_field |
473 | visibility_level | 473 | visibility_level |
474 | end | 474 | end |
475 | + | ||
476 | + def change_head(branch) | ||
477 | + gitlab_shell.update_repository_head(self.path_with_namespace, branch) | ||
478 | + reload_default_branch | ||
479 | + end | ||
475 | end | 480 | end |