summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKim Carlbäcker <kim.carlbacker@gmail.com>2017-12-20 18:29:52 +0000
committerKim Carlbäcker <kim.carlbacker@gmail.com>2017-12-20 18:29:52 +0000
commit28fba5ed99c6f8b4e7e534f9c2046d1c5ab38607 (patch)
tree2b4437f2a4a5584e937ece43507431a254d2bec6 /app/models
parentf5290c9738bbca7b130ddc86c0cdcc3f35e34c3a (diff)
downloadgitlab-ce-28fba5ed99c6f8b4e7e534f9c2046d1c5ab38607.tar.gz
Revert "Merge branch 'repo-write-ref-client-prep' into 'master'"revert-b655a4a7
This reverts merge request !15712
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/repository.rb16
2 files changed, 11 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 5183a216c53..3440c01b356 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1148,7 +1148,7 @@ class Project < ActiveRecord::Base
def change_head(branch)
if repository.branch_exists?(branch)
repository.before_change_head
- repository.write_ref('HEAD', "refs/heads/#{branch}", force: true)
+ repository.write_ref('HEAD', "refs/heads/#{branch}")
repository.copy_gitattributes(branch)
repository.after_change_head
reload_default_branch
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 387428d90a6..a34f5e5439b 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -19,7 +19,6 @@ class Repository
attr_accessor :full_path, :disk_path, :project, :is_wiki
delegate :ref_name_for_sha, to: :raw_repository
- delegate :write_ref, to: :raw_repository
CreateTreeError = Class.new(StandardError)
@@ -256,10 +255,11 @@ class Repository
# This will still fail if the file is corrupted (e.g. 0 bytes)
begin
- write_ref(keep_around_ref_name(sha), sha, force: true)
- rescue Gitlab::Git::Repository::GitError => ex
- # Necessary because https://gitlab.com/gitlab-org/gitlab-ce/issues/20156
- return true if ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/
+ write_ref(keep_around_ref_name(sha), sha)
+ rescue Rugged::ReferenceError => ex
+ Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
+ rescue Rugged::OSError => ex
+ raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/
Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
end
@@ -269,6 +269,10 @@ class Repository
ref_exists?(keep_around_ref_name(sha))
end
+ def write_ref(ref_path, sha)
+ rugged.references.create(ref_path, sha, force: true)
+ end
+
def diverging_commit_counts(branch)
root_ref_hash = raw_repository.commit(root_ref).id
cache.fetch(:"diverging_commit_counts_#{branch.name}") do
@@ -1015,7 +1019,7 @@ class Repository
end
def create_ref(ref, ref_path)
- write_ref(ref_path, ref)
+ raw_repository.write_ref(ref_path, ref)
end
def ls_files(ref)