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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-13 15:08:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-13 15:08:29 +0300
commitcdd5eba514e79c7801ff2eeb76e915e3f31ca5d7 (patch)
treecce52f5607283999f173aefdfa28b5be708cfb96 /lib/gitlab/gitaly_client
parent8dae4070d259ad9d2e9016eeeb450efb95c80b1c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/gitaly_client')
-rw-r--r--lib/gitlab/gitaly_client/operation_service.rb32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb
index 5a1699541d0..d575c0f470d 100644
--- a/lib/gitlab/gitaly_client/operation_service.rb
+++ b/lib/gitlab/gitaly_client/operation_service.rb
@@ -101,6 +101,16 @@ module Gitlab
if pre_receive_error = response.pre_receive_error.presence
raise Gitlab::Git::PreReceiveError, pre_receive_error
end
+ rescue GRPC::BadStatus => e
+ detailed_error = decode_detailed_error(e)
+
+ case detailed_error&.error
+ when :custom_hook
+ raise Gitlab::Git::PreReceiveError.new(custom_hook_error_message(detailed_error.custom_hook),
+ fallback_message: e.details)
+ else
+ raise
+ end
end
def user_merge_to_ref(user, source_sha:, branch:, target_ref:, message:, first_parent_ref:, allow_conflicts: false)
@@ -164,14 +174,8 @@ module Gitlab
# These messages were returned from internal/allowed API calls
raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message)
when :custom_hook
- # Custom hooks may return messages via either stdout or stderr which have a specific prefix. If
- # that prefix is present we'll want to print the hook's output, otherwise we'll want to print the
- # Gitaly error as a fallback.
- custom_hook_error = detailed_error.custom_hook
- custom_hook_output = custom_hook_error.stderr.presence || custom_hook_error.stdout
- error_message = EncodingHelper.encode!(custom_hook_output)
-
- raise Gitlab::Git::PreReceiveError.new(error_message, fallback_message: e.details)
+ raise Gitlab::Git::PreReceiveError.new(custom_hook_error_message(detailed_error.custom_hook),
+ fallback_message: e.details)
when :reference_update
# We simply ignore any reference update errors which are typically an
# indicator of multiple RPC calls trying to update the same reference
@@ -308,10 +312,6 @@ module Gitlab
timeout: GitalyClient.long_timeout
)
- if response.git_error.presence
- raise Gitlab::Git::Repository::GitError, response.git_error
- end
-
response.squash_sha
rescue GRPC::BadStatus => e
detailed_error = decode_detailed_error(e)
@@ -550,6 +550,14 @@ module Gitlab
# Error Class might not be known to ruby yet
nil
end
+
+ def custom_hook_error_message(custom_hook_error)
+ # Custom hooks may return messages via either stdout or stderr which have a specific prefix. If
+ # that prefix is present we'll want to print the hook's output, otherwise we'll want to print the
+ # Gitaly error as a fallback.
+ custom_hook_output = custom_hook_error.stderr.presence || custom_hook_error.stdout
+ EncodingHelper.encode!(custom_hook_output)
+ end
end
end
end