Encode remote root ref
This commit is contained in:
		
							parent
							
								
									88239e941e
								
							
						
					
					
						commit
						42c061781a
					
				|  | @ -1,6 +1,8 @@ | ||||||
| module Gitlab | module Gitlab | ||||||
|   module GitalyClient |   module GitalyClient | ||||||
|     class RemoteService |     class RemoteService | ||||||
|  |       include Gitlab::EncodingHelper | ||||||
|  | 
 | ||||||
|       MAX_MSG_SIZE = 128.kilobytes.freeze |       MAX_MSG_SIZE = 128.kilobytes.freeze | ||||||
| 
 | 
 | ||||||
|       def self.exists?(remote_url) |       def self.exists?(remote_url) | ||||||
|  | @ -61,7 +63,7 @@ module Gitlab | ||||||
|         response = GitalyClient.call(@storage, :remote_service, |         response = GitalyClient.call(@storage, :remote_service, | ||||||
|                                      :find_remote_root_ref, request) |                                      :find_remote_root_ref, request) | ||||||
| 
 | 
 | ||||||
|         response.ref.presence |         encode_utf8(response.ref) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       def update_remote_mirror(ref_name, only_branches_matching) |       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' |       expect(repository.find_remote_root_ref('origin')).to eq 'master' | ||||||
|     end |     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 |     it 'returns nil when remote name is nil' do | ||||||
|       expect_any_instance_of(Gitlab::GitalyClient::RemoteService) |       expect_any_instance_of(Gitlab::GitalyClient::RemoteService) | ||||||
|         .not_to receive(:find_remote_root_ref) |         .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' |       expect(client.find_remote_root_ref('origin')).to eq 'master' | ||||||
|     end |     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 |   end | ||||||
| 
 | 
 | ||||||
|   describe '#update_remote_mirror' do |   describe '#update_remote_mirror' do | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue