diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /lib/gitlab/gitaly_client | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'lib/gitlab/gitaly_client')
-rw-r--r-- | lib/gitlab/gitaly_client/operation_service.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index fd794acb4dd..c17934f12c3 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -162,6 +162,14 @@ module Gitlab raise Gitlab::Git::CommitError, 'failed to apply merge to branch' unless branch_update.commit_id.present? Gitlab::Git::OperationService::BranchUpdate.from_gitaly(branch_update) + + rescue GRPC::BadStatus => e + decoded_error = decode_detailed_error(e) + + raise unless decoded_error.present? + + raise decoded_error + ensure request_enum.close end @@ -259,11 +267,10 @@ module Gitlab request_enum.close end - def user_squash(user, squash_id, start_sha, end_sha, author, message, time = Time.now.utc) + def user_squash(user, start_sha, end_sha, author, message, time = Time.now.utc) request = Gitaly::UserSquashRequest.new( repository: @gitaly_repo, user: Gitlab::Git::User.from_gitlab(user).to_gitaly, - squash_id: squash_id.to_s, start_sha: start_sha, end_sha: end_sha, author: Gitlab::Git::User.from_gitlab(author).to_gitaly, @@ -471,6 +478,31 @@ module Gitlab rescue RangeError raise ArgumentError, "Unknown action '#{action[:action]}'" end + + def decode_detailed_error(err) + # details could have more than one in theory, but we only have one to worry about for now. + detailed_error = err.to_rpc_status&.details&.first + + return unless detailed_error.present? + + prefix = %r{type\.googleapis\.com\/gitaly\.(?<error_type>.+)} + error_type = prefix.match(detailed_error.type_url)[:error_type] + + detailed_error = Gitaly.const_get(error_type, false).decode(detailed_error.value) + + case detailed_error.error + when :access_check + access_check_error = detailed_error.access_check + # These messages were returned from internal/allowed API calls + Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message) + else + # We're handling access_check only for now, but we'll add more detailed error types + nil + end + rescue NameError, NoMethodError + # Error Class might not be known to ruby yet + nil + end end end end |