summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-04-04 15:57:17 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-04-04 15:57:17 +0000
commit6c6eef939aceba7f6314e3a43e9d212029fc2cb5 (patch)
tree05e1c1bc76ce38dbafa799d31a58ea5a4580545f /lib
parent20e3ed60935ca2b28cf1f632c5ce75f8dbac8e10 (diff)
parent7f32ad7097b8badcad98a52b9373d67ce7f33184 (diff)
downloadgitlab-ce-6c6eef939aceba7f6314e3a43e9d212029fc2cb5.tar.gz
Merge branch '30400-fix-blob-highlighting-in-search' into 'master'
Fix blob highlighting in search Closes #30400 See merge request !10420
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/project_search_results.rb2
-rw-r--r--lib/gitlab/search_results.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index db325c00705..0b8959f2fb9 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -62,7 +62,7 @@ module Gitlab
data << line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
end
- OpenStruct.new(
+ FoundBlob.new(
filename: filename,
basename: basename,
ref: ref,
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index ccfa517e04b..efe8095beea 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -1,5 +1,26 @@
module Gitlab
class SearchResults
+ class FoundBlob
+ attr_reader :id, :filename, :basename, :ref, :startline, :data
+
+ def initialize(opts = {})
+ @id = opts.fetch(:id, nil)
+ @filename = opts.fetch(:filename, nil)
+ @basename = opts.fetch(:basename, nil)
+ @ref = opts.fetch(:ref, nil)
+ @startline = opts.fetch(:startline, nil)
+ @data = opts.fetch(:data, nil)
+ end
+
+ def path
+ filename
+ end
+
+ def no_highlighting?
+ false
+ end
+ end
+
attr_reader :current_user, :query
# Limit search results by passed projects