Commit c9de5be5 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'gitaly-mandatory-20180627-jv' into 'master'

Make Gitaly search and message RPC's mandatory

Closes gitaly#1202, gitaly#1201, gitaly#1199, gitaly#1198, and gitaly#951

See merge request gitlab-org/gitlab-ce!20210
parents 19f2dfc3 be5e6d58
......@@ -323,13 +323,7 @@ module Gitlab
end
def get_messages(repository, commit_ids)
repository.gitaly_migrate(:commit_messages) do |is_enabled|
if is_enabled
repository.gitaly_commit_client.get_commit_messages(commit_ids)
else
commit_ids.map { |id| [id, rugged_find(repository, id).message] }.to_h
end
end
end
end
......
......@@ -1316,16 +1316,7 @@ module Gitlab
safe_query = Regexp.escape(query)
ref ||= root_ref
gitaly_migrate(:search_files_by_content) do |is_enabled|
if is_enabled
gitaly_repository_client.search_files_by_content(ref, safe_query)
else
offset = 2
args = %W(grep -i -I -n -z --before-context #{offset} --after-context #{offset} -E -e #{safe_query} #{ref})
run_git(args).first.scrub.split(/^--\n/)
end
end
end
def can_be_merged?(source_sha, target_branch)
......@@ -1342,15 +1333,7 @@ module Gitlab
return [] if empty? || safe_query.blank?
gitaly_migrate(:search_files_by_name) do |is_enabled|
if is_enabled
gitaly_repository_client.search_files_by_name(ref, safe_query)
else
args = %W(ls-tree -r --name-status --full-tree #{ref} -- #{safe_query})
run_git(args).first.lines.map(&:strip)
end
end
end
def find_commits_by_message(query, ref, path, limit, offset)
......
......@@ -28,18 +28,7 @@ module Gitlab
end
def get_messages(repository, tag_ids)
repository.gitaly_migrate(:tag_messages) do |is_enabled|
if is_enabled
repository.gitaly_ref_client.get_tag_messages(tag_ids)
else
tag_ids.map do |id|
tag = repository.rugged.lookup(id)
message = tag.is_a?(Rugged::Commit) ? "" : tag.message
[id, message]
end.to_h
end
end
end
end
......
......@@ -664,7 +664,7 @@ describe Repository do
end
end
shared_examples "search_files_by_content" do
describe "search_files_by_content" do
let(:results) { repository.search_files_by_content('feature', 'master') }
subject { results }
......@@ -711,7 +711,7 @@ describe Repository do
end
end
shared_examples "search_files_by_name" do
describe "search_files_by_name" do
let(:results) { repository.search_files_by_name('files', 'master') }
it 'returns result' do
......@@ -751,16 +751,6 @@ describe Repository do
end
end
describe 'with gitaly enabled' do
it_behaves_like 'search_files_by_content'
it_behaves_like 'search_files_by_name'
end
describe 'with gitaly disabled', :disable_gitaly do
it_behaves_like 'search_files_by_content'
it_behaves_like 'search_files_by_name'
end
describe '#async_remove_remote' do
before do
masterrev = repository.find_branch('master').dereferenced_target
......
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