diff options
author | YarNayar <YarTheGreat@gmail.com> | 2017-01-11 07:20:32 +0300 |
---|---|---|
committer | YarNayar <YarTheGreat@gmail.com> | 2017-01-24 14:58:00 +0300 |
commit | 99404a5851a4b8bbba8a5786d7351f2d4b024092 (patch) | |
tree | b79389d46bd60d1ba9c7ca0c87fa76e0061700c2 /lib | |
parent | dd3ddcd72bbfec3ba5bbcd871a9ac68064be7501 (diff) |
Search feature: redirects to commit page if query is commit sha and only commit found
See !8028 and #24833
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/project_search_results.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/search_results.rb | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb index a66719706be..db325c00705 100644 --- a/lib/gitlab/project_search_results.rb +++ b/lib/gitlab/project_search_results.rb @@ -71,6 +71,14 @@ module Gitlab ) end + def single_commit_result? + commits_count == 1 && total_result_count == 1 + end + + def total_result_count + issues_count + merge_requests_count + milestones_count + notes_count + blobs_count + wiki_blobs_count + commits_count + end + private def blobs @@ -122,7 +130,7 @@ module Gitlab commits = find_commits_by_message(query) commit_by_sha = find_commit_by_sha(query) - commits << commit_by_sha if commit_by_sha && !commits.include?(commit_by_sha) + commits |= [commit_by_sha] if commit_by_sha commits end diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb index 35212992698..c9c65f76f4b 100644 --- a/lib/gitlab/search_results.rb +++ b/lib/gitlab/search_results.rb @@ -43,6 +43,10 @@ module Gitlab @milestones_count ||= milestones.count end + def single_commit_result? + false + end + private def projects |