Use Gitlab::Git::Repository#gitaly_... more
This commit is contained in:
parent
6474c67d20
commit
20d415a676
7 changed files with 17 additions and 21 deletions
|
@ -142,7 +142,7 @@ module API
|
|||
project = Project.find_by_full_path(relative_path.sub(/\.(git|wiki)\z/, ''))
|
||||
|
||||
begin
|
||||
Gitlab::GitalyClient::Notifications.new(project.repository_storage, relative_path).post_receive
|
||||
Gitlab::GitalyClient::Notifications.new(project.repository).post_receive
|
||||
rescue GRPC::Unavailable => e
|
||||
render_api_error(e, 500)
|
||||
end
|
||||
|
|
|
@ -973,7 +973,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def gitaly_channel
|
||||
Gitlab::GitalyClient::Util.channel(@repository_storage)
|
||||
Gitlab::GitalyClient.get_channel(@repository_storage)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -1255,7 +1255,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def gitaly_ref_client
|
||||
@gitaly_ref_client ||= Gitlab::GitalyClient::Ref.new(@repository_storage, @relative_path)
|
||||
@gitaly_ref_client ||= Gitlab::GitalyClient::Ref.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,14 +3,14 @@ module Gitlab
|
|||
class Notifications
|
||||
attr_accessor :stub
|
||||
|
||||
def initialize(repository_storage, relative_path)
|
||||
@channel = Util.channel(repository_storage)
|
||||
@repository = Util.repository(repository_storage, relative_path)
|
||||
@stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: @channel)
|
||||
# 'repository' is a Gitlab::Git::Repository
|
||||
def initialize(repository)
|
||||
@gitaly_repo = repository.gitaly_repository
|
||||
@stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
|
||||
end
|
||||
|
||||
def post_receive
|
||||
request = Gitaly::PostReceiveRequest.new(repository: @repository)
|
||||
request = Gitaly::PostReceiveRequest.new(repository: @gitaly_repo)
|
||||
@stub.post_receive(request)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,24 +3,24 @@ module Gitlab
|
|||
class Ref
|
||||
attr_accessor :stub
|
||||
|
||||
def initialize(repository_storage, relative_path)
|
||||
@channel = Util.channel(repository_storage)
|
||||
@repository = Util.repository(repository_storage, relative_path)
|
||||
@stub = Gitaly::Ref::Stub.new(nil, nil, channel_override: @channel)
|
||||
# 'repository' is a Gitlab::Git::Repository
|
||||
def initialize(repository)
|
||||
@gitaly_repo = repository.gitaly_repository
|
||||
@stub = Gitaly::Ref::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
|
||||
end
|
||||
|
||||
def default_branch_name
|
||||
request = Gitaly::FindDefaultBranchNameRequest.new(repository: @repository)
|
||||
request = Gitaly::FindDefaultBranchNameRequest.new(repository: @gitaly_repo)
|
||||
stub.find_default_branch_name(request).name.gsub(/^refs\/heads\//, '')
|
||||
end
|
||||
|
||||
def branch_names
|
||||
request = Gitaly::FindAllBranchNamesRequest.new(repository: @repository)
|
||||
request = Gitaly::FindAllBranchNamesRequest.new(repository: @gitaly_repo)
|
||||
consume_refs_response(stub.find_all_branch_names(request), prefix: 'refs/heads/')
|
||||
end
|
||||
|
||||
def tag_names
|
||||
request = Gitaly::FindAllTagNamesRequest.new(repository: @repository)
|
||||
request = Gitaly::FindAllTagNamesRequest.new(repository: @gitaly_repo)
|
||||
consume_refs_response(stub.find_all_tag_names(request), prefix: 'refs/tags/')
|
||||
end
|
||||
|
||||
|
|
|
@ -9,10 +9,6 @@ module Gitlab
|
|||
relative_path: relative_path,
|
||||
)
|
||||
end
|
||||
|
||||
def channel(repository_storage)
|
||||
GitalyClient.get_channel(repository_storage)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Notifications do
|
|||
describe '#post_receive' do
|
||||
let(:project) { create(:empty_project) }
|
||||
let(:repo_path) { project.repository.path_to_repo }
|
||||
subject { described_class.new(project.repository_storage, project.full_path + '.git') }
|
||||
subject { described_class.new(project.repository) }
|
||||
|
||||
it 'sends a post_receive message' do
|
||||
expect_any_instance_of(Gitaly::Notifications::Stub).
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe Gitlab::GitalyClient::Ref do
|
||||
let(:project) { create(:empty_project) }
|
||||
let(:repo_path) { project.repository.path_to_repo }
|
||||
let(:client) { Gitlab::GitalyClient::Ref.new(project.repository_storage, project.full_path + '.git') }
|
||||
let(:client) { Gitlab::GitalyClient::Ref.new(project.repository) }
|
||||
|
||||
before do
|
||||
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
|
||||
|
|
Loading…
Reference in a new issue