From c609c898ff7f42c3d72a1c6d619e1ff786f5e18a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 17 Nov 2021 12:11:55 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/finders/tags_finder.rb | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'app/finders/tags_finder.rb') diff --git a/app/finders/tags_finder.rb b/app/finders/tags_finder.rb index 36ca2c7f281..6bc5419e704 100644 --- a/app/finders/tags_finder.rb +++ b/app/finders/tags_finder.rb @@ -5,9 +5,36 @@ class TagsFinder < GitRefsFinder super(repository, params) end - def execute - tags = repository.tags_sorted_by(sort) + def execute(gitaly_pagination: false) + tags = if gitaly_pagination + repository.tags_sorted_by(sort, pagination_params) + else + repository.tags_sorted_by(sort) + end by_search(tags) + + rescue ArgumentError => e + raise Gitlab::Git::InvalidPageToken, "Invalid page token: #{page_token}" if e.message.include?('page token') + + raise + end + + def total + repository.tag_count + end + + private + + def per_page + params[:per_page].presence + end + + def page_token + "#{Gitlab::Git::TAG_REF_PREFIX}#{@params[:page_token]}" if params[:page_token] + end + + def pagination_params + { limit: per_page, page_token: page_token } end end -- cgit v1.2.3