summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikita Verkhovin <vernik91@gmail.com>2015-05-17 23:32:58 +0600
committerNikita Verkhovin <vernik91@gmail.com>2015-05-18 13:09:13 +0600
commit241f5971ba657960a316fd3e43c7db5a6de41969 (patch)
tree2b58520a34edcc1069ef61e847a98fb0b46fa5d6 /lib
parentc74b49c2e0a991c5d3ddaacbf8d2022891a36f3a (diff)
downloadgitlab-ce-241f5971ba657960a316fd3e43c7db5a6de41969.tar.gz
Add search issues/MR by number
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/search_results.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index 75a3dfe37c3..06245374bc8 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -51,11 +51,23 @@ module Gitlab
end
def issues
- Issue.where(project_id: limit_project_ids).full_search(query).order('updated_at DESC')
+ issues = Issue.where(project_id: limit_project_ids)
+ if query =~ /#(\d+)\z/
+ issues = issues.where(iid: $1)
+ else
+ issues = issues.full_search(query)
+ end
+ issues.order('updated_at DESC')
end
def merge_requests
- MergeRequest.in_projects(limit_project_ids).full_search(query).order('updated_at DESC')
+ merge_requests = MergeRequest.in_projects(limit_project_ids)
+ if query =~ /[#!](\d+)\z/
+ merge_requests = merge_requests.where(iid: $1)
+ else
+ merge_requests = merge_requests.full_search(query)
+ end
+ merge_requests.order('updated_at DESC')
end
def default_scope