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
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-12-12 19:36:58 +0300
committerRobert Speicher <robert@gitlab.com>2017-12-12 19:36:58 +0300
commitb655a4a790b05f6023563b35a3823728480c33fc (patch)
tree3d179933792e405809148060faae000d482def40 /lib
parent2cbfc992c9005ed193b2d547a5537313dbf2ca0e (diff)
parentdad4c0b645d499c93fba14ce1e691da151929071 (diff)
Merge branch 'repo-write-ref-client-prep' into 'master'
Move Repository#write_ref to Git::Repository#write_ref Closes gitaly#793 See merge request gitlab-org/gitlab-ce!15712
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/repository.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index fbdd646ea13..0e0a1987c7d 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1073,12 +1073,17 @@ module Gitlab
end
end
- def write_ref(ref_path, ref)
+ def write_ref(ref_path, ref, force: false)
raise ArgumentError, "invalid ref_path #{ref_path.inspect}" if ref_path.include?(' ')
raise ArgumentError, "invalid ref #{ref.inspect}" if ref.include?("\x00")
- input = "update #{ref_path}\x00#{ref}\x00\x00"
- run_git!(%w[update-ref --stdin -z]) { |stdin| stdin.write(input) }
+ ref = "refs/heads/#{ref}" unless ref.start_with?("refs") || ref =~ /\A[a-f0-9]+\z/i
+
+ rugged.references.create(ref_path, ref, force: force)
+ rescue Rugged::ReferenceError => ex
+ raise GitError, "could not create ref #{ref_path}: #{ex}"
+ rescue Rugged::OSError => ex
+ raise GitError, "could not create ref #{ref_path}: #{ex}"
end
def fetch_ref(source_repository, source_ref:, target_ref:)