diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-01 11:38:16 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-01 11:38:16 +0300 |
commit | 8775e4a1faf13a01451e71ea9ef729dc52e6d3c1 (patch) | |
tree | 8632c5465f6b3dee57bb0ccd64f5162c35b8ab15 /app/finders | |
parent | f63dc06cb4572db92bb91c936e9862c55f1f365e (diff) | |
parent | ca5cd7b7fb5108d30d0f6b74e31da736024592dd (diff) |
Merge branch 'id-stale-branches' into 'master'
Add endpoint for fetching diverging commit counts
See merge request gitlab-org/gitlab-ce!29802
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/branches_finder.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/finders/branches_finder.rb b/app/finders/branches_finder.rb index 45d5591e81b..b462c8053fa 100644 --- a/app/finders/branches_finder.rb +++ b/app/finders/branches_finder.rb @@ -9,6 +9,7 @@ class BranchesFinder def execute branches = repository.branches_sorted_by(sort) branches = by_search(branches) + branches = by_names(branches) branches end @@ -16,6 +17,10 @@ class BranchesFinder attr_reader :repository, :params + def names + @params[:names].presence + end + def search @params[:search].presence end @@ -59,4 +64,13 @@ class BranchesFinder def find_exact_match_index(matches, term) matches.index { |branch| branch.name.casecmp(term) == 0 } end + + def by_names(branches) + return branches unless names + + branch_names = names.to_set + branches.filter do |branch| + branch_names.include?(branch.name) + end + end end |