diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 00:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 00:08:53 +0300 |
commit | cfaf1cca4403b826af2286b1ab0a69ad01c58738 (patch) | |
tree | 89a4456977185bbe993ea091a3f5b13412bc811a /lib/gitlab/file_finder.rb | |
parent | 57e39452d861ff01ccd4c09243c0bd2a0947ad07 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/file_finder.rb')
-rw-r--r-- | lib/gitlab/file_finder.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/gitlab/file_finder.rb b/lib/gitlab/file_finder.rb index a71baadfdb3..d438b0415fa 100644 --- a/lib/gitlab/file_finder.rb +++ b/lib/gitlab/file_finder.rb @@ -13,14 +13,15 @@ module Gitlab @ref = ref end - def find(query) + def find(query, content_match_cutoff: nil) query = Gitlab::Search::Query.new(query, encode_binary: true) do filter :filename, matcher: ->(filter, blob) { blob.binary_path =~ /#{filter[:regex_value]}$/i } filter :path, matcher: ->(filter, blob) { blob.binary_path =~ /#{filter[:regex_value]}/i } filter :extension, matcher: ->(filter, blob) { blob.binary_path =~ /\.#{filter[:regex_value]}$/i } end - files = find_by_path(query.term) + find_by_content(query.term) + content_match_cutoff = nil if query.filters.any? + files = find_by_path(query.term) + find_by_content(query.term, { limit: content_match_cutoff }) files = query.filter_results(files) if query.filters.any? @@ -29,8 +30,8 @@ module Gitlab private - def find_by_content(query) - repository.search_files_by_content(query, ref).map do |result| + def find_by_content(query, options) + repository.search_files_by_content(query, ref, options).map do |result| Gitlab::Search::FoundBlob.new(content_match: result, project: project, ref: ref, repository: repository) end end |