summaryrefslogtreecommitdiff
path: root/app/contexts
diff options
context:
space:
mode:
authorJavier Castro <javier.alejandro.castro@gmail.com>2013-04-14 14:07:11 -0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-09 11:47:08 +0300
commit7f57fe5034f6fdfbdd4e29745b50e7bfa1576bf5 (patch)
tree29586c1f9dd79b73b88e1797e26b432f9d18fd40 /app/contexts
parent4353babe61a57be128bd967731e7c536c9a55ba3 (diff)
downloadgitlab-ce-7f57fe5034f6fdfbdd4e29745b50e7bfa1576bf5.tar.gz
Implemented code search feature
Diffstat (limited to 'app/contexts')
-rw-r--r--app/contexts/search_context.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb
index de6542e82f4..854c369ea4a 100644
--- a/app/contexts/search_context.rb
+++ b/app/contexts/search_context.rb
@@ -10,7 +10,11 @@ class SearchContext
return result unless query.present?
- result[:projects] = Project.where(id: project_ids).search(query).limit(10)
+ projects = Project.where(id: project_ids)
+ result[:projects] = projects.search(query).limit(10)
+ if projects.length == 1
+ result[:snippets] = projects.first.files(query, params[:branch_ref])
+ end
result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10)
result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10)
result[:wiki_pages] = []
@@ -22,7 +26,8 @@ class SearchContext
projects: [],
merge_requests: [],
issues: [],
- wiki_pages: []
+ wiki_pages: [],
+ snippets: []
}
end
end