diff options
Diffstat (limited to 'lib/gitlab/gitaly_client')
-rw-r--r-- | lib/gitlab/gitaly_client/commit_service.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/diff.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/operation_service.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/ref_service.rb | 31 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/wiki_page.rb | 2 |
6 files changed, 38 insertions, 19 deletions
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 1ef5b0f96c2..573e3547202 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -418,6 +418,9 @@ module Gitlab response = gitaly_client_call(@repository.storage, :commit_service, :raw_blame, request, timeout: GitalyClient.medium_timeout) response.reduce([]) { |memo, msg| memo << msg.data }.join + # Temporary fix, use structured errors when they are available: https://gitlab.com/gitlab-org/gitaly/-/issues/5594 + rescue GRPC::Internal + "" end def find_commit(revision) diff --git a/lib/gitlab/gitaly_client/diff.rb b/lib/gitlab/gitaly_client/diff.rb index dd192ccde1a..c30b8ab1bc8 100644 --- a/lib/gitlab/gitaly_client/diff.rb +++ b/lib/gitlab/gitaly_client/diff.rb @@ -3,7 +3,7 @@ module Gitlab module GitalyClient class Diff - ATTRS = %i(from_path to_path old_mode new_mode from_id to_id patch overflow_marker collapsed too_large).freeze + ATTRS = %i[from_path to_path old_mode new_mode from_id to_id patch overflow_marker collapsed too_large].freeze include AttributesBag end diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index fe76543548b..905588c2afc 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -553,7 +553,8 @@ module Gitlab message: encode_binary(message), start_branch_name: encode_binary(start_branch_name.to_s), start_repository: start_repository.gitaly_repository, - dry_run: dry_run + dry_run: dry_run, + timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i) ) gitaly_client_call( 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, diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index b2d5f9c7e13..9ea541e083d 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -237,22 +237,6 @@ module Gitlab ) end - def create_from_snapshot(http_url, http_auth) - request = Gitaly::CreateRepositoryFromSnapshotRequest.new( - repository: @gitaly_repo, - http_url: http_url, - http_auth: http_auth - ) - - gitaly_client_call( - @storage, - :repository_service, - :create_repository_from_snapshot, - request, - timeout: GitalyClient.long_timeout - ) - end - def write_ref(ref_path, ref, old_ref) request = Gitaly::WriteRefRequest.new( repository: @gitaly_repo, diff --git a/lib/gitlab/gitaly_client/wiki_page.rb b/lib/gitlab/gitaly_client/wiki_page.rb index 757a429fb8a..f6ea2c96bbb 100644 --- a/lib/gitlab/gitaly_client/wiki_page.rb +++ b/lib/gitlab/gitaly_client/wiki_page.rb @@ -3,7 +3,7 @@ module Gitlab module GitalyClient class WikiPage - ATTRS = %i(title format url_path path name historical raw_data).freeze + ATTRS = %i[title format url_path path name historical raw_data].freeze include AttributesBag include Gitlab::EncodingHelper |