From 241f5971ba657960a316fd3e43c7db5a6de41969 Mon Sep 17 00:00:00 2001 From: Nikita Verkhovin Date: Sun, 17 May 2015 23:32:58 +0600 Subject: Add search issues/MR by number --- lib/gitlab/search_results.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.1