Commit 908352d5 authored by Stan Hu's avatar Stan Hu

Merge branch '199220-hide-snippet-blob-search' into 'master'

Remove snippet content search

Closes #199220

See merge request gitlab-org/gitlab!26359
parents db2f8d97 e019d9d9
...@@ -5,6 +5,7 @@ class SearchController < ApplicationController ...@@ -5,6 +5,7 @@ class SearchController < ApplicationController
include SearchHelper include SearchHelper
include RendersCommits include RendersCommits
before_action :override_snippet_scope, only: :show
around_action :allow_gitaly_ref_name_caching around_action :allow_gitaly_ref_name_caching
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
...@@ -103,4 +104,14 @@ class SearchController < ApplicationController ...@@ -103,4 +104,14 @@ class SearchController < ApplicationController
Gitlab::UsageDataCounters::SearchCounter.increment_navbar_searches_count Gitlab::UsageDataCounters::SearchCounter.increment_navbar_searches_count
end end
# Disallow web snippet_blobs search as we migrate snippet
# from database-backed storage to git repository-based,
# and searching across multiple git repositories is not feasible.
#
# TODO: after 13.0 refactor this into Search::SnippetService
# See https://gitlab.com/gitlab-org/gitlab/issues/208882
def override_snippet_scope
params[:scope] = 'snippet_titles' if params[:snippets] == 'true'
end
end end
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
= users = users
- elsif @show_snippets - elsif @show_snippets
= search_filter_link 'snippet_blobs', _("Snippet Contents"), search: { snippets: true, group_id: nil, project_id: nil }
= search_filter_link 'snippet_titles', _("Titles and Filenames"), search: { snippets: true, group_id: nil, project_id: nil } = search_filter_link 'snippet_titles', _("Titles and Filenames"), search: { snippets: true, group_id: nil, project_id: nil }
- else - else
= search_filter_link 'projects', _("Projects"), data: { qa_selector: 'projects_tab' } = search_filter_link 'projects', _("Projects"), data: { qa_selector: 'projects_tab' }
......
---
title: Remove and deprecate snippet content search
merge_request: 26359
author:
type: removed
...@@ -255,6 +255,8 @@ Example response: ...@@ -255,6 +255,8 @@ Example response:
### Scope: snippet_blobs ### Scope: snippet_blobs
This scope will be disabled after GitLab 13.0.
```shell ```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/search?scope=snippet_blobs&search=test curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/search?scope=snippet_blobs&search=test
``` ```
......
...@@ -8,6 +8,7 @@ describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :sidekiq_ ...@@ -8,6 +8,7 @@ describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :sidekiq_
let(:authorized_project) { create(:project, namespace: authorized_user.namespace) } let(:authorized_project) { create(:project, namespace: authorized_user.namespace) }
before do before do
skip('Snippet content search will be disabled indefinitely')
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true) stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
authorized_project.add_maintainer(authorized_user) authorized_project.add_maintainer(authorized_user)
......
...@@ -18284,9 +18284,6 @@ msgstr "" ...@@ -18284,9 +18284,6 @@ msgstr ""
msgid "Smartcard authentication failed: client certificate header is missing." msgid "Smartcard authentication failed: client certificate header is missing."
msgstr "" msgstr ""
msgid "Snippet Contents"
msgstr ""
msgid "Snippets" msgid "Snippets"
msgstr "" msgstr ""
......
...@@ -140,6 +140,14 @@ describe SearchController do ...@@ -140,6 +140,14 @@ describe SearchController do
end end
end end
context 'snippet search' do
it 'forces title search' do
get :show, params: { scope: 'snippet_blobs', snippets: 'true', search: 'foo' }
expect(assigns[:scope]).to eq('snippet_titles')
end
end
it 'finds issue comments' do it 'finds issue comments' do
project = create(:project, :public) project = create(:project, :public)
note = create(:note_on_issue, project: project) note = create(:note_on_issue, project: project)
......
...@@ -16,45 +16,4 @@ describe 'Search Snippets' do ...@@ -16,45 +16,4 @@ describe 'Search Snippets' do
expect(page).to have_link(public_snippet.title) expect(page).to have_link(public_snippet.title)
expect(page).to have_link(private_snippet.title) expect(page).to have_link(private_snippet.title)
end end
it 'User searches for snippet contents' do
create(:personal_snippet,
:public,
title: 'Many lined snippet',
content: <<-CONTENT.strip_heredoc
|line one
|line two
|line three
|line four
|line five
|line six
|line seven
|line eight
|line nine
|line ten
|line eleven
|line twelve
|line thirteen
|line fourteen
CONTENT
)
sign_in create(:user)
visit dashboard_snippets_path
submit_search('line seven')
expect(page).to have_content('line seven')
# 3 lines before the matched line should be visible
expect(page).to have_content('line six')
expect(page).to have_content('line five')
expect(page).to have_content('line four')
expect(page).not_to have_content('line three')
# 3 lines after the matched line should be visible
expect(page).to have_content('line eight')
expect(page).to have_content('line nine')
expect(page).to have_content('line ten')
expect(page).not_to have_content('line eleven')
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment