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:
authorMark Chao <mchao@gitlab.com>2018-10-04 12:16:51 +0300
committerMark Chao <mchao@gitlab.com>2018-10-30 10:44:55 +0300
commita4ba973e24ef6767d635c0291c9b6ce8085aef28 (patch)
tree28efdf13b834db6267fd8bd64d798d8e694b0109 /lib/gitlab/search_results.rb
parentbc14e4ed1024efa1e0a411bd59e1339fb1af20c0 (diff)
Allow FoundBlob to access language from gitattributes
Extract language_from_git_attributes as a concern so it can ben included in two blob classes.
Diffstat (limited to 'lib/gitlab/search_results.rb')
-rw-r--r--lib/gitlab/search_results.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index 6c86ad11385..b46c18c4364 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -5,8 +5,9 @@ module Gitlab
class FoundBlob
include EncodingHelper
include Presentable
+ include BlobLanguageFromGitAttributes
- attr_reader :id, :filename, :basename, :ref, :startline, :data, :project_id
+ attr_reader :id, :filename, :basename, :ref, :startline, :data, :project
def initialize(opts = {})
@id = opts.fetch(:id, nil)
@@ -16,17 +17,15 @@ module Gitlab
@startline = opts.fetch(:startline, nil)
@data = encode_utf8(opts.fetch(:data, nil))
@per_page = opts.fetch(:per_page, 20)
- @project_id = opts.fetch(:project_id, nil)
+ @project = opts.fetch(:project, nil)
end
def path
filename
end
- # Since search results often contain many items,
- # not triggering lookup can avoid n+1 queries.
- def language_from_gitattributes
- nil
+ def project_id
+ @project&.id
end
def present