summaryrefslogtreecommitdiff
path: root/app/finders/branches_finder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/branches_finder.rb')
-rw-r--r--app/finders/branches_finder.rb26
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