diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-14 10:15:49 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-14 10:15:49 +0000 |
commit | 5e829934f95bcae25f5c09583b6febe6e2e646b6 (patch) | |
tree | 48b65e3a3125f23594d9d7bdf728f71aa7e224d5 /lib/api | |
parent | e7595c10bc14cd32c456b9c6a94e227d41d6d09a (diff) | |
parent | b0b4ae1875529cd7ca786bd5eccd49be9a40a038 (diff) | |
download | gitlab-ce-5e829934f95bcae25f5c09583b6febe6e2e646b6.tar.gz |
Merge branch '42934-search-api-fix' into 'master'
Add information about projects when searching in wiki_blobs, blobs, commits scopes
Closes #42934
See merge request gitlab-org/gitlab-ce!17095
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/search.rb | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c8cda85b170..e9e32ac76fe 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -274,6 +274,7 @@ module API expose :stats, using: Entities::CommitStats, if: :stats expose :status expose :last_pipeline, using: 'API::Entities::PipelineBasic' + expose :project_id end class BasicRef < Grape::Entity @@ -1176,6 +1177,7 @@ module API expose :id expose :ref expose :startline + expose :project_id end end end diff --git a/lib/api/search.rb b/lib/api/search.rb index b9982e03bb3..3556ad98c52 100644 --- a/lib/api/search.rb +++ b/lib/api/search.rb @@ -11,7 +11,7 @@ module API projects: Entities::BasicProjectDetails, milestones: Entities::Milestone, notes: Entities::Note, - commits: Entities::Commit, + commits: Entities::CommitDetail, blobs: Entities::Blob, wiki_blobs: Entities::Blob, snippet_titles: Entities::Snippet, @@ -35,7 +35,7 @@ module API def process_results(results) case params[:scope] when 'wiki_blobs' - paginate(results).map { |blob| Gitlab::ProjectSearchResults.parse_search_result(blob) } + paginate(results).map { |blob| Gitlab::ProjectSearchResults.parse_search_result(blob, user_project) } when 'blobs' paginate(results).map { |blob| blob[1] } else @@ -85,9 +85,7 @@ module API use :pagination end get ':id/-/search' do - group = find_group!(params[:id]) - - present search(group_id: group.id), with: entity + present search(group_id: user_group.id), with: entity end end @@ -106,9 +104,7 @@ module API use :pagination end get ':id/-/search' do - project = find_project!(params[:id]) - - present search(project_id: project.id), with: entity + present search(project_id: user_project.id), with: entity end end end |