diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/gitaly_client/ref_service.rb | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/gitaly_client/ref_service.rb')
-rw-r--r-- | lib/gitlab/gitaly_client/ref_service.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb index 45edfd4cbbf..c251c126b07 100644 --- a/lib/gitlab/gitaly_client/ref_service.rb +++ b/lib/gitlab/gitaly_client/ref_service.rb @@ -122,6 +122,37 @@ module Gitlab end end + def update_refs(ref_list:) + request = Enumerator.new do |y| + ref_list.each_slice(100) do |refs| + updates = refs.map do |ref_pair| + Gitaly::UpdateReferencesRequest::Update.new( + old_object_id: ref_pair[:old_sha], + new_object_id: ref_pair[:new_sha], + reference: encode_binary(ref_pair[:reference]) + ) + end + + y.yield Gitaly::UpdateReferencesRequest.new(repository: @gitaly_repo, updates: updates) + end + end + + gitaly_client_call(@repository.storage, :ref_service, :update_references, request, timeout: GitalyClient.long_timeout) + rescue GRPC::BadStatus => e + detailed_error = GitalyClient.decode_detailed_error(e) + + case detailed_error.try(:error) + when :invalid_format + raise Gitlab::Git::InvalidRefFormatError, "references have an invalid format: #{detailed_error.invalid_format.refs.join(",")}" + when :references_locked + raise Gitlab::Git::ReferencesLockedError + when :reference_state_mismatch + raise Gitlab::Git::ReferenceStateMismatchError + else + raise e + end + end + def delete_refs(refs: [], except_with_prefixes: []) request = Gitaly::DeleteRefsRequest.new( repository: @gitaly_repo, |