Update repository head when change default project branch
This commit is contained in:
parent
0705a7a507
commit
58427749fd
2 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue