diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 13:16:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 13:16:36 +0000 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /app/finders/tags_finder.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) | |
download | gitlab-ce-311b0269b4eb9839fa63f80c8d7a58f32b8138a0.tar.gz |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'app/finders/tags_finder.rb')
-rw-r--r-- | app/finders/tags_finder.rb | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/app/finders/tags_finder.rb b/app/finders/tags_finder.rb index 0ccbbdc1b87..6bc5419e704 100644 --- a/app/finders/tags_finder.rb +++ b/app/finders/tags_finder.rb @@ -5,11 +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), nil] - rescue Gitlab::Git::CommandError => e - [[], e] + 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 |