diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/finders/branches_finder.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/finders/branches_finder.rb')
-rw-r--r-- | app/finders/branches_finder.rb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/app/finders/branches_finder.rb b/app/finders/branches_finder.rb index 8001c70a9b2..2eee90a512a 100644 --- a/app/finders/branches_finder.rb +++ b/app/finders/branches_finder.rb @@ -5,11 +5,15 @@ class BranchesFinder < GitRefsFinder super(repository, params) end - def execute - branches = repository.branches_sorted_by(sort) - branches = by_search(branches) - branches = by_names(branches) - branches + def execute(gitaly_pagination: false) + if gitaly_pagination && names.blank? && search.blank? + repository.branches_sorted_by(sort, pagination_params) + else + branches = repository.branches_sorted_by(sort) + branches = by_search(branches) + branches = by_names(branches) + branches + end end private @@ -18,6 +22,18 @@ class BranchesFinder < GitRefsFinder @params[:names].presence end + def per_page + @params[:per_page].presence + end + + def page_token + "#{Gitlab::Git::BRANCH_REF_PREFIX}#{@params[:page_token]}" if @params[:page_token] + end + + def pagination_params + { limit: per_page, page_token: page_token } + end + def by_names(branches) return branches unless names |