diff options
| -rw-r--r-- | app/observers/project_observer.rb | 6 | ||||
| -rw-r--r-- | lib/gitlab/backend/shell.rb | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index 3d4d161a1a2..c1a4611536d 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -13,6 +13,12 @@ class ProjectObserver < BaseObserver def after_update(project) project.send_move_instructions if project.namespace_id_changed? project.rename_repo if project.path_changed? + + GitlabShellWorker.perform_async( + :update_repository_head, + project.path_with_namespace, + project.default_branch + ) if project.default_branch_changed? end def before_destroy(project) diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 991648f3f79..8bced609e08 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -36,6 +36,18 @@ module Gitlab system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" end + # Update HEAD for repository + # + # path - project path with namespace + # branch - repository branch name + # + # Ex. + # update_repository_head("gitlab/gitlab-ci", "3-1-stable") + # + def update_repository_head(path, branch) + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", "#{path}.git", branch + end + # Fork repository to new namespace # # path - project path with namespace |
