Commit 58427749fd553ce802f037a7bdbbfd30f9df232a
1 parent
0705a7a5
Exists in
master
and in
4 other branches
Update repository head when change default project branch
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
app/observers/project_observer.rb
| @@ -13,6 +13,12 @@ class ProjectObserver < BaseObserver | @@ -13,6 +13,12 @@ class ProjectObserver < BaseObserver | ||
| 13 | def after_update(project) | 13 | def after_update(project) |
| 14 | project.send_move_instructions if project.namespace_id_changed? | 14 | project.send_move_instructions if project.namespace_id_changed? |
| 15 | project.rename_repo if project.path_changed? | 15 | project.rename_repo if project.path_changed? |
| 16 | + | ||
| 17 | + GitlabShellWorker.perform_async( | ||
| 18 | + :update_repository_head, | ||
| 19 | + project.path_with_namespace, | ||
| 20 | + project.default_branch | ||
| 21 | + ) if project.default_branch_changed? | ||
| 16 | end | 22 | end |
| 17 | 23 | ||
| 18 | def before_destroy(project) | 24 | def before_destroy(project) |
lib/gitlab/backend/shell.rb
| @@ -36,6 +36,18 @@ module Gitlab | @@ -36,6 +36,18 @@ module Gitlab | ||
| 36 | system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" | 36 | system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | + # Update HEAD for repository | ||
| 40 | + # | ||
| 41 | + # path - project path with namespace | ||
| 42 | + # branch - repository branch name | ||
| 43 | + # | ||
| 44 | + # Ex. | ||
| 45 | + # update_repository_head("gitlab/gitlab-ci", "3-1-stable") | ||
| 46 | + # | ||
| 47 | + def update_repository_head(path, branch) | ||
| 48 | + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", "#{path}.git", branch | ||
| 49 | + end | ||
| 50 | + | ||
| 39 | # Fork repository to new namespace | 51 | # Fork repository to new namespace |
| 40 | # | 52 | # |
| 41 | # path - project path with namespace | 53 | # path - project path with namespace |