diff options
author | bunufi <dainius.stn@gmail.com> | 2018-03-05 12:57:47 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-05 12:57:47 +0000 |
commit | 47d4890d3ad8a1c2ecb2b9c497d537c044c76e25 (patch) | |
tree | df257cd59e7af3df53d219b6e8e4e704f5e46f1d /lib/api | |
parent | bd57be280d6dede47844a23a487a24bbbc49201c (diff) | |
download | gitlab-ce-47d4890d3ad8a1c2ecb2b9c497d537c044c76e25.tar.gz |
Update API: add search param to branches
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/branches.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 1794207e29b..13cfba728fa 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -16,6 +16,10 @@ module API render_api_error!('The branch refname is invalid', 400) end end + + params :filter_params do + optional :search, type: String, desc: 'Return list of branches matching the search criteria' + end end params do @@ -27,15 +31,23 @@ module API end params do use :pagination + use :filter_params end get ':id/repository/branches' do Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42329') repository = user_project.repository - branches = ::Kaminari.paginate_array(repository.branches.sort_by(&:name)) + + branches = BranchesFinder.new(repository, declared_params(include_missing: false)).execute + merged_branch_names = repository.merged_branch_names(branches.map(&:name)) - present paginate(branches), with: Entities::Branch, project: user_project, merged_branch_names: merged_branch_names + present( + paginate(::Kaminari.paginate_array(branches)), + with: Entities::Branch, + project: user_project, + merged_branch_names: merged_branch_names + ) end resource ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do |