Commit bd0971bd authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '7211-geo-synchronization-does-not-seem-to-replicate-default-branch-all-the-time' into 'master'

Backport Gitlab::Git::Repository#find_remote_root_ref to CE

See merge request gitlab-org/gitlab-ce!21507
parents 44d251ed 460badd8
...@@ -425,7 +425,7 @@ group :ed25519 do ...@@ -425,7 +425,7 @@ group :ed25519 do
end end
# Gitaly GRPC client # Gitaly GRPC client
gem 'gitaly-proto', '~> 0.113.0', require: 'gitaly' gem 'gitaly-proto', '~> 0.117.0', require: 'gitaly'
gem 'grpc', '~> 1.11.0' gem 'grpc', '~> 1.11.0'
# Locked until https://github.com/google/protobuf/issues/4210 is closed # Locked until https://github.com/google/protobuf/issues/4210 is closed
......
...@@ -276,7 +276,7 @@ GEM ...@@ -276,7 +276,7 @@ GEM
gettext_i18n_rails (>= 0.7.1) gettext_i18n_rails (>= 0.7.1)
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gitaly-proto (0.113.0) gitaly-proto (0.117.0)
google-protobuf (~> 3.1) google-protobuf (~> 3.1)
grpc (~> 1.10) grpc (~> 1.10)
github-linguist (5.3.3) github-linguist (5.3.3)
...@@ -1038,7 +1038,7 @@ DEPENDENCIES ...@@ -1038,7 +1038,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly-proto (~> 0.113.0) gitaly-proto (~> 0.117.0)
github-linguist (~> 5.3.3) github-linguist (~> 5.3.3)
gitlab-flowdock-git-hook (~> 1.0.1) gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-gollum-lib (~> 4.2) gitlab-gollum-lib (~> 4.2)
......
...@@ -279,7 +279,7 @@ GEM ...@@ -279,7 +279,7 @@ GEM
gettext_i18n_rails (>= 0.7.1) gettext_i18n_rails (>= 0.7.1)
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gitaly-proto (0.113.0) gitaly-proto (0.117.0)
google-protobuf (~> 3.1) google-protobuf (~> 3.1)
grpc (~> 1.10) grpc (~> 1.10)
github-linguist (5.3.3) github-linguist (5.3.3)
...@@ -1047,7 +1047,7 @@ DEPENDENCIES ...@@ -1047,7 +1047,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly-proto (~> 0.113.0) gitaly-proto (~> 0.117.0)
github-linguist (~> 5.3.3) github-linguist (~> 5.3.3)
gitlab-flowdock-git-hook (~> 1.0.1) gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-gollum-lib (~> 4.2) gitlab-gollum-lib (~> 4.2)
......
...@@ -666,6 +666,14 @@ module Gitlab ...@@ -666,6 +666,14 @@ module Gitlab
end end
end end
def find_remote_root_ref(remote_name)
return unless remote_name.present?
wrapped_gitaly_errors do
gitaly_remote_client.find_remote_root_ref(remote_name)
end
end
AUTOCRLF_VALUES = { AUTOCRLF_VALUES = {
"true" => true, "true" => true,
"false" => false, "false" => false,
......
...@@ -52,6 +52,18 @@ module Gitlab ...@@ -52,6 +52,18 @@ module Gitlab
response.result response.result
end end
def find_remote_root_ref(remote_name)
request = Gitaly::FindRemoteRootRefRequest.new(
repository: @gitaly_repo,
remote: remote_name
)
response = GitalyClient.call(@storage, :remote_service,
:find_remote_root_ref, request)
response.ref.presence
end
def update_remote_mirror(ref_name, only_branches_matching) def update_remote_mirror(ref_name, only_branches_matching)
req_enum = Enumerator.new do |y| req_enum = Enumerator.new do |y|
y.yield Gitaly::UpdateRemoteMirrorRequest.new( y.yield Gitaly::UpdateRemoteMirrorRequest.new(
......
...@@ -583,6 +583,33 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -583,6 +583,33 @@ describe Gitlab::Git::Repository, :seed_helper do
end end
end end
describe '#find_remote_root_ref' do
it 'gets the remote root ref from GitalyClient' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.to receive(:find_remote_root_ref).and_call_original
expect(repository.find_remote_root_ref('origin')).to eq 'master'
end
it 'returns nil when remote name is nil' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref)
expect(repository.find_remote_root_ref(nil)).to be_nil
end
it 'returns nil when remote name is empty' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref)
expect(repository.find_remote_root_ref('')).to be_nil
end
it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RemoteService, :find_remote_root_ref do
subject { repository.find_remote_root_ref('origin') }
end
end
describe "#log" do describe "#log" do
shared_examples 'repository log' do shared_examples 'repository log' do
let(:commit_with_old_name) do let(:commit_with_old_name) do
......
...@@ -45,6 +45,17 @@ describe Gitlab::GitalyClient::RemoteService do ...@@ -45,6 +45,17 @@ describe Gitlab::GitalyClient::RemoteService do
end end
end end
describe '#find_remote_root_ref' do
it 'sends an find_remote_root_ref message and returns the root ref' do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(double(ref: 'master'))
expect(client.find_remote_root_ref('origin')).to eq 'master'
end
end
describe '#update_remote_mirror' do describe '#update_remote_mirror' do
let(:ref_name) { 'remote_mirror_1' } let(:ref_name) { 'remote_mirror_1' }
let(:only_branches_matching) { ['my-branch', 'master'] } let(:only_branches_matching) { ['my-branch', 'master'] }
......
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