From 02d6da5f73c180a334f86a22e1adb39451528c77 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Wed, 30 Jun 2021 09:37:12 +0200 Subject: ruby: Remove UserRebaseConfirmable implementation In [1] we removed all code to call the Ruby implementation of UserRebaseConfirmable. This happened in the previous minor release so now it's time to remove the Ruby implementation completely. 1. 8f5574579 (UserRebaseConfirmable: Remove feature flag, 2021-05-31) --- ruby/lib/gitaly_server/operations_service.rb | 48 ---------------------------- ruby/lib/gitlab/git/repository.rb | 37 --------------------- ruby/spec/lib/gitlab/git/repository_spec.rb | 37 --------------------- 3 files changed, 122 deletions(-) (limited to 'ruby') diff --git a/ruby/lib/gitaly_server/operations_service.rb b/ruby/lib/gitaly_server/operations_service.rb index af2318203..a643eb4b6 100644 --- a/ruby/lib/gitaly_server/operations_service.rb +++ b/ruby/lib/gitaly_server/operations_service.rb @@ -2,45 +2,6 @@ module GitalyServer class OperationsService < Gitaly::OperationService::Service include Utils - # rubocop:disable Metrics/AbcSize - def user_rebase_confirmable(session, call) - Enumerator.new do |y| - header = session.next.header - transaction = Praefect::Transaction.from_metadata(call.metadata) - - repo = Gitlab::Git::Repository.from_gitaly(header.repository, call) - user = Gitlab::Git::User.from_gitaly(header.user) - remote_repository = Gitlab::Git::GitalyRemoteRepository.new(header.remote_repository, call) - - begin - repo.rebase( - user, - header.rebase_id, - branch: header.branch, - branch_sha: header.branch_sha, - remote_repository: remote_repository, - remote_branch: header.remote_branch, - push_options: Gitlab::Git::PushOptions.new(header.git_push_options), - timestamp: header.timestamp, - transaction: transaction - ) do |rebase_sha| - y << Gitaly::UserRebaseConfirmableResponse.new(rebase_sha: rebase_sha) - - raise GRPC::FailedPrecondition.new('rebase aborted by client') unless session.next.apply - end - - y << Gitaly::UserRebaseConfirmableResponse.new(rebase_applied: true) - rescue Gitlab::Git::PreReceiveError => e - y << Gitaly::UserRebaseConfirmableResponse.new(pre_receive_error: set_utf8!(e.message)) - rescue Gitlab::Git::Repository::GitError => e - y << Gitaly::UserRebaseConfirmableResponse.new(git_error: set_utf8!(e.message)) - rescue Gitlab::Git::CommitError => e - raise GRPC::FailedPrecondition.new(e.message) - end - end - end - # rubocop:enable Metrics/AbcSize - def user_apply_patch(call) stream = call.each_remote_read first_request = stream.next @@ -72,14 +33,5 @@ module GitalyServer branch_created: gitlab_update_result.branch_created ) end - - def get_param!(request, name) - value = request[name.to_s] - - return value if value.present? - - field_name = name.to_s.tr('_', ' ') - raise GRPC::InvalidArgument.new("empty #{field_name}") - end end end diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index fad18e5b2..ae84b5300 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -9,10 +9,6 @@ module Gitlab include Gitlab::EncodingHelper include Gitlab::Utils::StrongMemoize - # In https://gitlab.com/gitlab-org/gitaly/merge_requests/698 - # We copied this prefix into gitaly-go, so don't change it - # or things will break! (REBASE_WORKTREE_PREFIX) - REBASE_WORKTREE_PREFIX = 'rebase'.freeze AM_WORKTREE_PREFIX = 'am'.freeze GITALY_INTERNAL_URL = 'ssh://gitaly/internal.git'.freeze AUTOCRLF_VALUES = { 'true' => true, 'false' => false, 'input' => :input }.freeze @@ -209,39 +205,6 @@ module Gitlab rugged.diff(sha1, sha2).size.positive? end - # rubocop:disable Metrics/ParameterLists - def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:, push_options: nil, timestamp: nil, transaction: nil) - worktree = Gitlab::Git::Worktree.new(path, REBASE_WORKTREE_PREFIX, rebase_id) - env = user.git_env(timestamp) - - with_repo_branch_commit(remote_repository, remote_branch) do |commit| - diff_range = "#{commit.sha}...#{branch}" - diff_files = begin - run_git!( - %W[diff --name-only #{diff_range}] - ).chomp - rescue GitError - [] - end - - with_worktree(worktree, branch, sparse_checkout_files: diff_files, env: env) do - run_git!( - %W[rebase #{commit.sha}], - chdir: worktree.path, env: env, include_stderr: true - ) - - rebase_sha = run_git!(%w[rev-parse HEAD], chdir: worktree.path, env: env).strip - - yield rebase_sha if block_given? - - update_branch(branch, user: user, newrev: rebase_sha, oldrev: branch_sha, push_options: push_options, transaction: transaction) - - rebase_sha - end - end - end - # rubocop:enable Metrics/ParameterLists - def commit_patches(start_point, patches, extra_env: {}) worktree = Gitlab::Git::Worktree.new(path, AM_WORKTREE_PREFIX, SecureRandom.hex) diff --git a/ruby/spec/lib/gitlab/git/repository_spec.rb b/ruby/spec/lib/gitlab/git/repository_spec.rb index 6bbf4bcff..5061d1f41 100644 --- a/ruby/spec/lib/gitlab/git/repository_spec.rb +++ b/ruby/spec/lib/gitlab/git/repository_spec.rb @@ -328,43 +328,6 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength end end - describe '#rebase' do - let(:repository) { mutable_repository } - let(:rebase_id) { '2' } - let(:branch_name) { 'rd-add-file-larger-than-1-mb' } - let(:branch_sha) { 'c54ad072fabee9f7bf9b2c6c67089db97ebfbecd' } - let(:remote_branch) { 'master' } - - subject do - opts = { - branch: branch_name, - branch_sha: branch_sha, - remote_repository: repository, - remote_branch: remote_branch - } - - repository.rebase(user, rebase_id, **opts) - end - - describe 'sparse checkout' do - let(:expected_files) { %w[files/images/emoji.png] } - - it 'lists files modified in source branch in sparse-checkout' do - allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args, **kwargs| - m.call(*args, **kwargs) do - worktree = args[0] - sparse = repository.path + "/worktrees/#{worktree.name}/info/sparse-checkout" - diff_files = IO.readlines(sparse, chomp: true) - - expect(diff_files).to eq(expected_files) - end - end - - subject - end - end - end - describe '#cleanup' do context 'when Rugged has been called' do it 'calls close on Rugged::Repository' do -- cgit v1.2.3