Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb13
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