diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-04 23:04:10 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-06 22:01:48 +0300 |
commit | 460badd8cca3a515bbcae5235c14c09cc907abaf (patch) | |
tree | 9fdb65e562dba755189fc2e5cd61038a4d9d056c | |
parent | 21096e2391e3e4c5d8e6ab1d430189429847248d (diff) |
Add Gitlab::Git::Repository#find_remote_root_ref
-rw-r--r-- | lib/gitlab/git/repository.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 27 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 9521a2d63a0..74a1bfb273a 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -666,6 +666,14 @@ module Gitlab 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 = { "true" => true, "false" => false, diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 17348b01006..1098a266140 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -583,6 +583,33 @@ describe Gitlab::Git::Repository, :seed_helper do 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 shared_examples 'repository log' do let(:commit_with_old_name) do |