Commit 143ace07 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'gitaly-has-local-branches' into 'master'

Use Gitaly's RepositoryService.HasLocalBranches RPC

See merge request gitlab-org/gitlab-ce!14753
parents 22ade6e7 06e7eeb1
......@@ -193,7 +193,7 @@ module Gitlab
def has_local_branches?
gitaly_migrate(:has_local_branches) do |is_enabled|
if is_enabled
gitaly_ref_client.has_local_branches?
gitaly_repository_client.has_local_branches?
else
has_local_branches_rugged?
end
......
......@@ -57,14 +57,6 @@ module Gitlab
branch_names.count
end
# TODO implement a more efficient RPC for this https://gitlab.com/gitlab-org/gitaly/issues/616
def has_local_branches?
request = Gitaly::FindAllBranchNamesRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :ref_service, :find_all_branch_names, request).first
response&.names.present?
end
def local_branches(sort_by: nil)
request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo)
request.sort_by = sort_by_param(sort_by) if sort_by
......
......@@ -58,6 +58,13 @@ module Gitlab
request = Gitaly::CreateRepositoryRequest.new(repository: @gitaly_repo)
GitalyClient.call(@storage, :repository_service, :create_repository, request)
end
def has_local_branches?
request = Gitaly::HasLocalBranchesRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :repository_service, :has_local_branches, request)
response.value
end
end
end
end
......@@ -73,4 +73,15 @@ describe Gitlab::GitalyClient::RepositoryService do
client.apply_gitattributes(revision)
end
end
describe '#has_local_branches?' do
it 'sends a has_local_branches message' do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:has_local_branches)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(double(value: true))
expect(client.has_local_branches?).to be(true)
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