diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /lib/gitlab/gitaly_client | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'lib/gitlab/gitaly_client')
-rw-r--r-- | lib/gitlab/gitaly_client/blob_service.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/commit_service.rb | 38 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/conflicts_service.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/operation_service.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 12 |
5 files changed, 92 insertions, 12 deletions
diff --git a/lib/gitlab/gitaly_client/blob_service.rb b/lib/gitlab/gitaly_client/blob_service.rb index 6d87c3329d7..cd7b9a3c095 100644 --- a/lib/gitlab/gitaly_client/blob_service.rb +++ b/lib/gitlab/gitaly_client/blob_service.rb @@ -22,6 +22,32 @@ module Gitlab consume_blob_response(response) end + def list_all_blobs(limit: nil, bytes_limit: 0, dynamic_timeout: nil, ignore_alternate_object_directories: false) + repository = @gitaly_repo + + if ignore_alternate_object_directories + repository = @gitaly_repo.dup.tap do |g_repo| + g_repo.git_alternate_object_directories = Google::Protobuf::RepeatedField.new(:string) + end + end + + request = Gitaly::ListAllBlobsRequest.new( + repository: repository, + limit: limit, + bytes_limit: bytes_limit + ) + + timeout = + if dynamic_timeout + [dynamic_timeout, GitalyClient.medium_timeout].min + else + GitalyClient.medium_timeout + end + + response = Gitlab::GitalyClient.call(repository.storage_name, :blob_service, :list_all_blobs, request, timeout: timeout) + GitalyClient::BlobsStitcher.new(GitalyClient::ListBlobsAdapter.new(response)) + end + def list_blobs(revisions, limit: 0, bytes_limit: 0, with_paths: false, dynamic_timeout: nil) request = Gitaly::ListBlobsRequest.new( repository: @gitaly_repo, diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index c10f780665c..1ef5b0f96c2 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -274,8 +274,10 @@ module Gitlab # else # defaults to :include_merges behavior # ['foo_bar.rb', 'bar_baz.rb'], # - def find_changed_paths(commits, merge_commit_diff_mode: nil) - request = find_changed_paths_request(commits, merge_commit_diff_mode) + def find_changed_paths(objects, merge_commit_diff_mode: nil) + request = find_changed_paths_request(objects, merge_commit_diff_mode) + + return [] if request.nil? response = gitaly_client_call(@repository.storage, :diff_service, :find_changed_paths, request, timeout: GitalyClient.medium_timeout) response.flat_map do |msg| @@ -587,6 +589,15 @@ module Gitlab Hash[commit_refs] end + def get_patch_id(old_revision, new_revision) + request = Gitaly::GetPatchIDRequest + .new(repository: @gitaly_repo, old_revision: old_revision, new_revision: new_revision) + + response = gitaly_client_call(@repository.storage, :diff_service, :get_patch_id, request, timeout: GitalyClient.medium_timeout) + + response.patch_id + end + private def parse_global_options!(options) @@ -646,16 +657,27 @@ module Gitlab response.commit end - def find_changed_paths_request(commits, merge_commit_diff_mode) + def find_changed_paths_request(objects, merge_commit_diff_mode) diff_mode = MERGE_COMMIT_DIFF_MODES[merge_commit_diff_mode] if Feature.enabled?(:merge_commit_diff_modes) - commit_requests = commits.map do |commit| - Gitaly::FindChangedPathsRequest::Request.new( - commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: commit) - ) + requests = objects.filter_map do |object| + case object + when Gitlab::Git::DiffTree + Gitaly::FindChangedPathsRequest::Request.new( + tree_request: Gitaly::FindChangedPathsRequest::Request::TreeRequest.new(left_tree_revision: object.left_tree_id, right_tree_revision: object.right_tree_id) + ) + when Commit, Gitlab::Git::Commit + next if object.sha.blank? || Gitlab::Git.blank_ref?(object.sha) + + Gitaly::FindChangedPathsRequest::Request.new( + commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: object.sha) + ) + end end - Gitaly::FindChangedPathsRequest.new(repository: @gitaly_repo, requests: commit_requests, merge_commit_diff_mode: diff_mode) + return if requests.blank? + + Gitaly::FindChangedPathsRequest.new(repository: @gitaly_repo, requests: requests, merge_commit_diff_mode: diff_mode) end def path_error_message(path_error) diff --git a/lib/gitlab/gitaly_client/conflicts_service.rb b/lib/gitlab/gitaly_client/conflicts_service.rb index 38f648ccc31..ffe65307c80 100644 --- a/lib/gitlab/gitaly_client/conflicts_service.rb +++ b/lib/gitlab/gitaly_client/conflicts_service.rb @@ -17,19 +17,21 @@ module Gitlab self.repository_actor = repository end - def list_conflict_files(allow_tree_conflicts: false) + def list_conflict_files(allow_tree_conflicts: false, skip_content: false) request = Gitaly::ListConflictFilesRequest.new( repository: @gitaly_repo, our_commit_oid: @our_commit_oid, their_commit_oid: @their_commit_oid, - allow_tree_conflicts: allow_tree_conflicts + allow_tree_conflicts: allow_tree_conflicts, + skip_content: skip_content ) response = gitaly_client_call(@repository.storage, :conflicts_service, :list_conflict_files, request, timeout: GitalyClient.long_timeout) GitalyClient::ConflictFilesStitcher.new(response, @gitaly_repo) end def conflicts? - list_conflict_files.any? + skip_content = Feature.enabled?(:skip_conflict_files_in_gitaly, type: :experiment) + list_conflict_files(skip_content: skip_content).any? rescue GRPC::FailedPrecondition, GRPC::Unknown # The server raises FailedPrecondition when it encounters # ConflictSideMissing, which means a conflict exists but its `theirs` or diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index 67e135bb530..fe76543548b 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -135,7 +135,7 @@ module Gitlab end end - def user_merge_to_ref(user, source_sha:, branch:, target_ref:, message:, first_parent_ref:) + def user_merge_to_ref(user, source_sha:, branch:, target_ref:, message:, first_parent_ref:, expected_old_oid: "") request = Gitaly::UserMergeToRefRequest.new( repository: @gitaly_repo, source_sha: source_sha, @@ -144,6 +144,7 @@ module Gitlab user: Gitlab::Git::User.from_gitlab(user).to_gitaly, message: encode_binary(message), first_parent_ref: encode_binary(first_parent_ref), + expected_old_oid: expected_old_oid, timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i) ) @@ -344,6 +345,23 @@ module Gitlab request_enum.close end + def user_rebase_to_ref(user, source_sha:, target_ref:, first_parent_ref:, expected_old_oid: "") + request = Gitaly::UserRebaseToRefRequest.new( + user: Gitlab::Git::User.from_gitlab(user).to_gitaly, + repository: @gitaly_repo, + source_sha: source_sha, + target_ref: encode_binary(target_ref), + first_parent_ref: encode_binary(first_parent_ref), + expected_old_oid: expected_old_oid, + timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i) + ) + + response = gitaly_client_call(@repository.storage, :operation_service, + :user_rebase_to_ref, request, timeout: GitalyClient.long_timeout) + + response.commit_id + end + def user_squash(user, start_sha, end_sha, author, message, time = Time.now.utc) request = Gitaly::UserSquashRequest.new( repository: @gitaly_repo, diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index b5b7d94b4d0..b2d5f9c7e13 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -363,6 +363,18 @@ module Gitlab ) end + def object_pool + request = Gitaly::GetObjectPoolRequest.new(repository: @gitaly_repo) + + gitaly_client_call( + @storage, + :object_pool_service, + :get_object_pool, + request, + timeout: GitalyClient.medium_timeout + ) + end + private def search_results_from_response(gitaly_response, options = {}) |