diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:22:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:22:29 +0300 |
commit | 61d81025139e2e6b3706c05eee4e60ff13417323 (patch) | |
tree | 517dc8ebc4a9f8d74fd77eb7bd6d5466d5184d94 /app/models/repository.rb | |
parent | 25fc1060affe576fd7c2f8aad586c5109c51cf7e (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-ee
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 1bd61fe48cb..a77aaf02e06 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -466,6 +466,7 @@ class Repository # Runs code after the HEAD of a repository is changed. def after_change_head expire_all_method_caches + container.after_repository_change_head end # Runs code after a new commit has been pushed. @@ -1142,6 +1143,18 @@ class Repository Gitlab::CurrentSettings.pick_repository_storage end + def change_head(branch) + if branch_exists?(branch) + before_change_head + raw_repository.write_ref('HEAD', "refs/heads/#{branch}") + copy_gitattributes(branch) + after_change_head + else + container.errors.add(:base, _("Could not change HEAD: branch '%{branch}' does not exist") % { branch: branch }) + false + end + end + private # TODO Genericize finder, later split this on finders by Ref or Oid |