Encode remote root ref

This commit is contained in:
Douglas Barbosa Alexandre 2018-09-07 01:46:12 -03:00
parent 88239e941e
commit 42c061781a
No known key found for this signature in database
GPG key ID: F1E98EF6393565A0
3 changed files with 16 additions and 1 deletions

View file

@ -1,6 +1,8 @@
module Gitlab
module GitalyClient
class RemoteService
include Gitlab::EncodingHelper
MAX_MSG_SIZE = 128.kilobytes.freeze
def self.exists?(remote_url)
@ -61,7 +63,7 @@ module Gitlab
response = GitalyClient.call(@storage, :remote_service,
:find_remote_root_ref, request)
response.ref.presence
encode_utf8(response.ref)
end
def update_remote_mirror(ref_name, only_branches_matching)

View file

@ -591,6 +591,10 @@ describe Gitlab::Git::Repository, :seed_helper do
expect(repository.find_remote_root_ref('origin')).to eq 'master'
end
it 'returns UTF-8' do
expect(repository.find_remote_root_ref('origin')).to be_utf8
end
it 'returns nil when remote name is nil' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref)

View file

@ -54,6 +54,15 @@ describe Gitlab::GitalyClient::RemoteService do
expect(client.find_remote_root_ref('origin')).to eq 'master'
end
it 'ensure ref is a valid UTF-8 string' 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: "an_invalid_ref_\xE5"))
expect(client.find_remote_root_ref('origin')).to eq "an_invalid_ref_å"
end
end
describe '#update_remote_mirror' do