diff options
author | Rémy Coutable <remy@rymai.me> | 2018-01-16 17:24:36 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-16 17:24:36 +0300 |
commit | a7d172625a8a8f31eb7730a343951c0de2436da0 (patch) | |
tree | 455d0fbe1c7d323540aefb8d9bbddea7b9d32dc5 /lib | |
parent | 093856a75ed4a354286f7e6fc7a0f08d9d95a431 (diff) | |
parent | 91939161aace35823f7a60b25647d5e23285c556 (diff) |
Merge branch '41666-cannot-search-with-keyword-merge' into 'master'
Resolve "Cannot search with keyword "merge""
Closes #41666
See merge request gitlab-org/gitlab-ce!16462
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/project_search_results.rb | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb index e2662fc362b..7771b15069b 100644 --- a/lib/gitlab/project_search_results.rb +++ b/lib/gitlab/project_search_results.rb @@ -44,25 +44,20 @@ module Gitlab ref = nil filename = nil basename = nil + data = "" startline = 0 - result.each_line.each_with_index do |line, index| - matches = line.match(/^(?<ref>[^:]*):(?<filename>.*):(?<startline>\d+):/) - if matches + result.strip.each_line.each_with_index do |line, index| + prefix ||= line.match(/^(?<ref>[^:]*):(?<filename>.*)\x00(?<startline>\d+)\x00/)&.tap do |matches| ref = matches[:ref] filename = matches[:filename] startline = matches[:startline] startline = startline.to_i - index extname = Regexp.escape(File.extname(filename)) basename = filename.sub(/#{extname}$/, '') - break end - end - - data = "" - result.each_line do |line| - data << line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '') + data << line.sub(prefix.to_s, '') end FoundBlob.new( |