diff options
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/lib/gitaly_server/operations_service.rb | 48 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/operation_service.rb | 5 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/repository.rb | 48 | ||||
-rw-r--r-- | ruby/proto/gitaly/blob_pb.rb | 17 | ||||
-rw-r--r-- | ruby/proto/gitaly/blob_services_pb.rb | 4 | ||||
-rw-r--r-- | ruby/proto/gitaly/version.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitaly_server/sentry_interceptor_spec.rb | 4 |
7 files changed, 24 insertions, 104 deletions
diff --git a/ruby/lib/gitaly_server/operations_service.rb b/ruby/lib/gitaly_server/operations_service.rb index 9aae9b84a..af2318203 100644 --- a/ruby/lib/gitaly_server/operations_service.rb +++ b/ruby/lib/gitaly_server/operations_service.rb @@ -2,54 +2,6 @@ module GitalyServer class OperationsService < Gitaly::OperationService::Service include Utils - def user_update_branch(request, call) - repo = Gitlab::Git::Repository.from_gitaly(request.repository, call) - branch_name = get_param!(request, :branch_name) - newrev = get_param!(request, :newrev) - oldrev = get_param!(request, :oldrev) - gitaly_user = get_param!(request, :user) - transaction = Praefect::Transaction.from_metadata(call.metadata) - - user = Gitlab::Git::User.from_gitaly(gitaly_user) - repo.update_branch(branch_name, user: user, newrev: newrev, oldrev: oldrev, transaction: transaction) - - Gitaly::UserUpdateBranchResponse.new - rescue Gitlab::Git::Repository::InvalidRef, Gitlab::Git::CommitError => ex - raise GRPC::FailedPrecondition.new(ex.message) - rescue Gitlab::Git::PreReceiveError => ex - Gitaly::UserUpdateBranchResponse.new(pre_receive_error: set_utf8!(ex.message)) - end - - def user_revert(request, call) - repo = Gitlab::Git::Repository.from_gitaly(request.repository, call) - user = Gitlab::Git::User.from_gitaly(request.user) - commit = Gitlab::Git::Commit.new(repo, request.commit) - start_repository = Gitlab::Git::GitalyRemoteRepository.new(request.start_repository || request.repository, call) - - result = repo.revert( - user: user, - commit: commit, - branch_name: request.branch_name, - message: request.message.dup, - start_branch_name: request.start_branch_name.presence, - start_repository: start_repository, - dry_run: request.dry_run, - timestamp: request.timestamp - ) - - branch_update = branch_update_result(result) - Gitaly::UserRevertResponse.new(branch_update: branch_update) - rescue Gitlab::Git::Repository::CreateTreeError => e - Gitaly::UserRevertResponse.new( - create_tree_error: set_utf8!(e.message), - create_tree_error_code: e.error.upcase - ) - rescue Gitlab::Git::CommitError => e - Gitaly::UserRevertResponse.new(commit_error: set_utf8!(e.message)) - rescue Gitlab::Git::PreReceiveError => e - Gitaly::UserRevertResponse.new(pre_receive_error: set_utf8!(e.message)) - end - # rubocop:disable Metrics/AbcSize def user_rebase_confirmable(session, call) Enumerator.new do |y| diff --git a/ruby/lib/gitlab/git/operation_service.rb b/ruby/lib/gitlab/git/operation_service.rb index 0ae429be0..b10ffeb44 100644 --- a/ruby/lib/gitlab/git/operation_service.rb +++ b/ruby/lib/gitlab/git/operation_service.rb @@ -56,11 +56,6 @@ module Gitlab end end - def update_branch(branch_name, newrev, oldrev, push_options: nil, transaction: nil) - ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name - update_ref_in_hooks(ref, newrev, oldrev, push_options: push_options, transaction: transaction) - end - # Yields the given block (which should return a commit) and # writes it to the ref while also executing hooks for it. # The ref is _always_ overwritten (nothing is taken from its diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index 678849def..a4d21f5e2 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -205,41 +205,6 @@ module Gitlab false end - def update_branch(branch_name, user:, newrev:, oldrev:, push_options: nil, transaction: nil) - OperationService.new(user, self).update_branch(branch_name, newrev, oldrev, push_options: push_options, transaction: transaction) - end - - # rubocop:disable Metrics/ParameterLists - def revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false, timestamp: nil) - OperationService.new(user, self).with_branch( - branch_name, - start_branch_name: start_branch_name, - start_repository: start_repository - ) do |start_commit| - - revert_tree_id = check_revert_content(commit, start_commit.sha) - - if dry_run - # At this point the tree has been written to the object database but - # not committed, so we'll leave it to be cleaned up by `gc`. - # - # The response expects a SHA, so just return the starting one. - start_commit.sha - else - committer = user_to_committer(user, timestamp) - - create_commit( - message: message, - author: committer, - committer: committer, - tree: revert_tree_id, - parents: [start_commit.sha] - ) - end - end - end - # rubocop:enable Metrics/ParameterLists - def diff_exists?(sha1, sha2) rugged.diff(sha1, sha2).size.positive? end @@ -499,19 +464,6 @@ module Gitlab output end - def check_revert_content(target_commit, source_sha) - args = [target_commit.sha, source_sha] - args << { mainline: 1 } if target_commit.merge_commit? - - revert_index = rugged.revert_commit(*args) - raise CreateTreeError, :conflict if revert_index.conflicts? - - tree_id = revert_index.write_tree(rugged) - raise CreateTreeError, :empty unless diff_exists?(source_sha, tree_id) - - tree_id - end - def branches_filter(filter: nil, sort_by: nil) branches = rugged.branches.each(filter).map do |rugged_ref| begin diff --git a/ruby/proto/gitaly/blob_pb.rb b/ruby/proto/gitaly/blob_pb.rb index 77d5a22f5..6805ee63b 100644 --- a/ruby/proto/gitaly/blob_pb.rb +++ b/ruby/proto/gitaly/blob_pb.rb @@ -36,6 +36,20 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :path, :bytes, 7 optional :type, :enum, 8, "gitaly.ObjectType" end + add_message "gitaly.ListBlobsRequest" do + optional :repository, :message, 1, "gitaly.Repository" + repeated :revisions, :string, 2 + optional :limit, :uint32, 3 + optional :bytes_limit, :int64, 4 + end + add_message "gitaly.ListBlobsResponse" do + repeated :blobs, :message, 1, "gitaly.ListBlobsResponse.Blob" + end + add_message "gitaly.ListBlobsResponse.Blob" do + optional :oid, :string, 1 + optional :size, :int64, 2 + optional :data, :bytes, 3 + end add_message "gitaly.LFSPointer" do optional :size, :int64, 1 optional :data, :bytes, 2 @@ -77,6 +91,9 @@ module Gitaly GetBlobsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsRequest").msgclass GetBlobsRequest::RevisionPath = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsRequest.RevisionPath").msgclass GetBlobsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsResponse").msgclass + ListBlobsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.ListBlobsRequest").msgclass + ListBlobsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.ListBlobsResponse").msgclass + ListBlobsResponse::Blob = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.ListBlobsResponse.Blob").msgclass LFSPointer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.LFSPointer").msgclass NewBlobObject = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.NewBlobObject").msgclass GetLFSPointersRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetLFSPointersRequest").msgclass diff --git a/ruby/proto/gitaly/blob_services_pb.rb b/ruby/proto/gitaly/blob_services_pb.rb index 1048b21da..a6cdce7de 100644 --- a/ruby/proto/gitaly/blob_services_pb.rb +++ b/ruby/proto/gitaly/blob_services_pb.rb @@ -19,6 +19,10 @@ module Gitaly # response rpc :GetBlob, Gitaly::GetBlobRequest, stream(Gitaly::GetBlobResponse) rpc :GetBlobs, Gitaly::GetBlobsRequest, stream(Gitaly::GetBlobsResponse) + # ListBlobs will list all blobs reachable from a given set of revisions by + # doing a graph walk. It is not valid to pass revisions which do not resolve + # to an existing object. + rpc :ListBlobs, Gitaly::ListBlobsRequest, stream(Gitaly::ListBlobsResponse) # GetLFSPointers retrieves LFS pointers from a given set of object IDs. # This RPC filters all requested objects and only returns those which refer # to a valid LFS pointer. diff --git a/ruby/proto/gitaly/version.rb b/ruby/proto/gitaly/version.rb index 6e6903559..077923d02 100644 --- a/ruby/proto/gitaly/version.rb +++ b/ruby/proto/gitaly/version.rb @@ -2,5 +2,5 @@ # (https://gitlab.com/gitlab-org/release-tools/), and should not be # modified. module Gitaly - VERSION = '14.0.0-rc2' + VERSION = '14.1.0-rc1' end diff --git a/ruby/spec/lib/gitaly_server/sentry_interceptor_spec.rb b/ruby/spec/lib/gitaly_server/sentry_interceptor_spec.rb index 4163c1cb7..3711a616c 100644 --- a/ruby/spec/lib/gitaly_server/sentry_interceptor_spec.rb +++ b/ruby/spec/lib/gitaly_server/sentry_interceptor_spec.rb @@ -45,7 +45,7 @@ describe GitalyServer::SentryInterceptor do let(:expected_tags) do call_metadata.merge( 'system' => 'gitaly-ruby', - 'gitaly-ruby.method' => 'GitalyServer::OperationsService#user_update_branch', + 'gitaly-ruby.method' => 'Gitaly::OperationService::Service#user_update_branch', Labkit::Correlation::CorrelationId::LOG_KEY => anything ) end @@ -68,7 +68,7 @@ describe GitalyServer::SentryInterceptor do it 'sends the exception to Sentry' do expect(Raven).to receive(:capture_exception).with( ex, - fingerprint: ['gitaly-ruby', 'GitalyServer::OperationsService#user_update_branch', 'unknown encoding'] + fingerprint: ['gitaly-ruby', 'Gitaly::OperationService::Service#user_update_branch', 'unknown encoding'] ) begin |