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:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-04 13:29:25 +0300
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-12-12 18:05:38 +0300
commitdad4c0b645d499c93fba14ce1e691da151929071 (patch)
tree4c06fa010755af6a3cbaf0f795f9f1681665144b /lib
parent2a181d68c810e89ff5d2e49999775d8b58adb394 (diff)
Move Repository#write_ref to Git::Repository#write_ref
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 73889328f36..0f28d68eb4b 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1069,12 +1069,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:)