diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/gitaly_client/ref_service.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/gitaly_client/ref_service.rb')
-rw-r--r-- | lib/gitlab/gitaly_client/ref_service.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb index 235eef4575e..c064811b1e7 100644 --- a/lib/gitlab/gitaly_client/ref_service.rb +++ b/lib/gitlab/gitaly_client/ref_service.rb @@ -77,8 +77,8 @@ module Gitlab consume_find_local_branches_response(response) end - def tags(sort_by: nil) - request = Gitaly::FindAllTagsRequest.new(repository: @gitaly_repo) + def tags(sort_by: nil, pagination_params: nil) + request = Gitaly::FindAllTagsRequest.new(repository: @gitaly_repo, pagination_params: pagination_params) request.sort_by = sort_tags_by_param(sort_by) if sort_by response = GitalyClient.call(@storage, :ref_service, :find_all_tags, request, timeout: GitalyClient.medium_timeout) @@ -194,18 +194,39 @@ module Gitlab raise ArgumentError, ex end + def list_refs(patterns = [Gitlab::Git::BRANCH_REF_PREFIX]) + request = Gitaly::ListRefsRequest.new( + repository: @gitaly_repo, + patterns: patterns + ) + + response = GitalyClient.call(@storage, :ref_service, :list_refs, request, timeout: GitalyClient.fast_timeout) + consume_list_refs_response(response) + end + def pack_refs request = Gitaly::PackRefsRequest.new(repository: @gitaly_repo) GitalyClient.call(@storage, :ref_service, :pack_refs, request, timeout: GitalyClient.long_timeout) end + def find_refs_by_oid(oid:, limit:) + request = Gitaly::FindRefsByOIDRequest.new(repository: @gitaly_repo, sort_field: :refname, oid: oid, limit: limit) + + response = GitalyClient.call(@storage, :ref_service, :find_refs_by_oid, request, timeout: GitalyClient.medium_timeout) + response&.refs&.to_a + end + private def consume_refs_response(response) response.flat_map { |message| message.names.map { |name| yield(name) } } end + def consume_list_refs_response(response) + response.flat_map(&:references) + end + def sort_local_branches_by_param(sort_by) sort_by = 'name' if sort_by == 'name_asc' |