diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 09:08:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 09:08:04 +0300 |
commit | 95a6825e19809cae0cee779c0ca3667b233a58f4 (patch) | |
tree | e5cb19ea02021cf67be33cfc30a5c4f59ccf10d5 /lib/gitlab/gitaly_client | |
parent | fcfafe81d1f1aa442c5a5c93cd27b5f5b798cb90 (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.rb | 111 |
1 files changed, 48 insertions, 63 deletions
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index 66f70ed9dc6..6865e76d4bb 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -40,11 +40,6 @@ module Gitlab ) response = gitaly_client_call(@repository.storage, :operation_service, :user_create_tag, request, timeout: GitalyClient.long_timeout) - if pre_receive_error = response.pre_receive_error.presence - raise Gitlab::Git::PreReceiveError, pre_receive_error - elsif response.exists - raise Gitlab::Git::Repository::TagExistsError - end Gitlab::Git::Tag.new(@repository, response.tag) rescue GRPC::BadStatus => e @@ -79,10 +74,6 @@ module Gitlab response = gitaly_client_call(@repository.storage, :operation_service, :user_create_branch, request, timeout: GitalyClient.long_timeout) - if response.pre_receive_error.present? - raise Gitlab::Git::PreReceiveError, response.pre_receive_error - end - branch = response.branch return unless branch @@ -128,12 +119,8 @@ module Gitlab user: Gitlab::Git::User.from_gitlab(user).to_gitaly ) - response = gitaly_client_call(@repository.storage, :operation_service, - :user_delete_branch, request, timeout: GitalyClient.long_timeout) - - if pre_receive_error = response.pre_receive_error.presence - raise Gitlab::Git::PreReceiveError, pre_receive_error - end + gitaly_client_call(@repository.storage, :operation_service, + :user_delete_branch, request, timeout: GitalyClient.long_timeout) rescue GRPC::BadStatus => e detailed_error = GitalyClient.decode_detailed_error(e) @@ -246,25 +233,54 @@ module Gitlab end def user_cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false) - call_cherry_pick_or_revert(:cherry_pick, - user: user, - commit: commit, - branch_name: branch_name, - message: message, - start_branch_name: start_branch_name, - start_repository: start_repository, - dry_run: dry_run) + response = call_cherry_pick_or_revert(:cherry_pick, + user: user, + commit: commit, + branch_name: branch_name, + message: message, + start_branch_name: start_branch_name, + start_repository: start_repository, + dry_run: dry_run) + + Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update) + rescue GRPC::BadStatus => e + detailed_error = GitalyClient.decode_detailed_error(e) + + case detailed_error&.error + when :access_check + access_check_error = detailed_error.access_check + # These messages were returned from internal/allowed API calls + raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message) + when :cherry_pick_conflict + raise Gitlab::Git::Repository::CreateTreeError, 'CONFLICT' + when :changes_already_applied + raise Gitlab::Git::Repository::CreateTreeError, 'EMPTY' + when :target_branch_diverged + raise Gitlab::Git::CommitError, 'branch diverged' + else + raise e + end end def user_revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false) - call_cherry_pick_or_revert(:revert, - user: user, - commit: commit, - branch_name: branch_name, - message: message, - start_branch_name: start_branch_name, - start_repository: start_repository, - dry_run: dry_run) + response = call_cherry_pick_or_revert(:revert, + user: user, + commit: commit, + branch_name: branch_name, + message: message, + start_branch_name: start_branch_name, + start_repository: start_repository, + dry_run: dry_run) + + if response.pre_receive_error.presence + raise Gitlab::Git::PreReceiveError, response.pre_receive_error + elsif response.commit_error.presence + raise Gitlab::Git::CommitError, response.commit_error + elsif response.create_tree_error.presence + raise Gitlab::Git::Repository::CreateTreeError, response.create_tree_error_code + end + + Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update) end def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:, push_options: []) @@ -520,7 +536,7 @@ module Gitlab dry_run: dry_run ) - response = gitaly_client_call( + gitaly_client_call( @repository.storage, :operation_service, :"user_#{rpc}", @@ -528,37 +544,6 @@ module Gitlab remote_storage: start_repository.storage, timeout: GitalyClient.long_timeout ) - - handle_cherry_pick_or_revert_response(response) - rescue GRPC::BadStatus => e - detailed_error = GitalyClient.decode_detailed_error(e) - - case detailed_error&.error - when :access_check - access_check_error = detailed_error.access_check - # These messages were returned from internal/allowed API calls - raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message) - when :cherry_pick_conflict - raise Gitlab::Git::Repository::CreateTreeError, 'CONFLICT' - when :changes_already_applied - raise Gitlab::Git::Repository::CreateTreeError, 'EMPTY' - when :target_branch_diverged - raise Gitlab::Git::CommitError, 'branch diverged' - else - raise e - end - end - - def handle_cherry_pick_or_revert_response(response) - if response.pre_receive_error.presence - raise Gitlab::Git::PreReceiveError, response.pre_receive_error - elsif response.commit_error.presence - raise Gitlab::Git::CommitError, response.commit_error - elsif response.create_tree_error.presence - raise Gitlab::Git::Repository::CreateTreeError, response.create_tree_error_code - end - - Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update) end # rubocop:disable Metrics/ParameterLists |