diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-19 15:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-19 15:10:08 +0300 |
commit | 1072f96e340ddad78e5dad6dfedc7c6e85fc53ea (patch) | |
tree | 573525bb3525f79cbb011f39ad11c11c6efea315 /app/models/repository.rb | |
parent | 8cc0a0aa965798e74826197d350472d235af2f84 (diff) |
Add latest changes from gitlab-org/gitlab@master
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 |