Commit 30311a8b authored by Stan Hu's avatar Stan Hu

Merge branch 'da-find-remote-root-ref' into 'master'

Encode remote root ref

See merge request gitlab-org/gitlab-ce!21583
parents 88239e94 42c06178
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)
......
......@@ -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)
......
......@@ -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
......
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