Commit 20d415a6 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use Gitlab::Git::Repository#gitaly_... more

parent 6474c67d
...@@ -142,7 +142,7 @@ module API ...@@ -142,7 +142,7 @@ module API
project = Project.find_by_full_path(relative_path.sub(/\.(git|wiki)\z/, '')) project = Project.find_by_full_path(relative_path.sub(/\.(git|wiki)\z/, ''))
begin begin
Gitlab::GitalyClient::Notifications.new(project.repository_storage, relative_path).post_receive Gitlab::GitalyClient::Notifications.new(project.repository).post_receive
rescue GRPC::Unavailable => e rescue GRPC::Unavailable => e
render_api_error(e, 500) render_api_error(e, 500)
end end
......
...@@ -973,7 +973,7 @@ module Gitlab ...@@ -973,7 +973,7 @@ module Gitlab
end end
def gitaly_channel def gitaly_channel
Gitlab::GitalyClient::Util.channel(@repository_storage) Gitlab::GitalyClient.get_channel(@repository_storage)
end end
private private
...@@ -1255,7 +1255,7 @@ module Gitlab ...@@ -1255,7 +1255,7 @@ module Gitlab
end end
def gitaly_ref_client 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 end
end end
......
...@@ -3,14 +3,14 @@ module Gitlab ...@@ -3,14 +3,14 @@ module Gitlab
class Notifications class Notifications
attr_accessor :stub attr_accessor :stub
def initialize(repository_storage, relative_path) # 'repository' is a Gitlab::Git::Repository
@channel = Util.channel(repository_storage) def initialize(repository)
@repository = Util.repository(repository_storage, relative_path) @gitaly_repo = repository.gitaly_repository
@stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: @channel) @stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
end end
def post_receive def post_receive
request = Gitaly::PostReceiveRequest.new(repository: @repository) request = Gitaly::PostReceiveRequest.new(repository: @gitaly_repo)
@stub.post_receive(request) @stub.post_receive(request)
end end
end end
......
...@@ -3,24 +3,24 @@ module Gitlab ...@@ -3,24 +3,24 @@ module Gitlab
class Ref class Ref
attr_accessor :stub attr_accessor :stub
def initialize(repository_storage, relative_path) # 'repository' is a Gitlab::Git::Repository
@channel = Util.channel(repository_storage) def initialize(repository)
@repository = Util.repository(repository_storage, relative_path) @gitaly_repo = repository.gitaly_repository
@stub = Gitaly::Ref::Stub.new(nil, nil, channel_override: @channel) @stub = Gitaly::Ref::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
end end
def default_branch_name 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\//, '') stub.find_default_branch_name(request).name.gsub(/^refs\/heads\//, '')
end end
def branch_names 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/') consume_refs_response(stub.find_all_branch_names(request), prefix: 'refs/heads/')
end end
def tag_names 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/') consume_refs_response(stub.find_all_tag_names(request), prefix: 'refs/tags/')
end end
......
...@@ -9,10 +9,6 @@ module Gitlab ...@@ -9,10 +9,6 @@ module Gitlab
relative_path: relative_path, relative_path: relative_path,
) )
end end
def channel(repository_storage)
GitalyClient.get_channel(repository_storage)
end
end end
end end
end end
......
...@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Notifications do ...@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Notifications do
describe '#post_receive' do describe '#post_receive' do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:repo_path) { project.repository.path_to_repo } 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 it 'sends a post_receive message' do
expect_any_instance_of(Gitaly::Notifications::Stub). expect_any_instance_of(Gitaly::Notifications::Stub).
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitalyClient::Ref do describe Gitlab::GitalyClient::Ref do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:repo_path) { project.repository.path_to_repo } 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 before do
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
......
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