Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/search/query.rb')
-rw-r--r--lib/gitlab/search/query.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/gitlab/search/query.rb b/lib/gitlab/search/query.rb
index 4c5fae87420..360bbc073c5 100644
--- a/lib/gitlab/search/query.rb
+++ b/lib/gitlab/search/query.rb
@@ -40,19 +40,24 @@ module Gitlab
query_tokens = parse_raw_query
filters = @filters.each_with_object([]) do |filter, parsed_filters|
- match = query_tokens.find { |part| part =~ /\A-?#{filter[:name]}:/ }
+ matches = query_tokens.select { |part| part =~ /\A-?#{filter[:name]}:/ }
- next unless match
+ next unless matches.any?
- input = match.split(':')[1..].join
- next if input.empty?
+ matches.each do |match|
+ query_filter = filter.dup
- filter[:negated] = match.start_with?("-")
- filter[:value] = parse_filter(filter, input.gsub(QUOTES_REGEXP, ''))
- filter[:regex_value] = Regexp.escape(filter[:value]).gsub('\*', '.*?')
- fragments << match
+ input = match.split(':')[1..].join
- parsed_filters << filter
+ next if input.empty?
+
+ query_filter[:negated] = match.start_with?("-")
+ query_filter[:value] = parse_filter(query_filter, input.gsub(QUOTES_REGEXP, ''))
+ query_filter[:regex_value] = Regexp.escape(query_filter[:value]).gsub('\*', '.*?')
+
+ fragments << match
+ parsed_filters << query_filter
+ end
end
query = (query_tokens - fragments).join(' ')