Correctly encode string params for Gitaly's TreeEntries RPC
This commit is contained in:
parent
646aae3e4f
commit
b7ebb447d7
|
@ -80,8 +80,8 @@ module Gitlab
|
||||||
def tree_entries(repository, revision, path)
|
def tree_entries(repository, revision, path)
|
||||||
request = Gitaly::GetTreeEntriesRequest.new(
|
request = Gitaly::GetTreeEntriesRequest.new(
|
||||||
repository: @gitaly_repo,
|
repository: @gitaly_repo,
|
||||||
revision: revision,
|
revision: GitalyClient.encode(revision),
|
||||||
path: path.presence || '.'
|
path: path.present? ? GitalyClient.encode(path) : '.'
|
||||||
)
|
)
|
||||||
|
|
||||||
response = GitalyClient.call(@repository.storage, :commit_service, :get_tree_entries, request)
|
response = GitalyClient.call(@repository.storage, :commit_service, :get_tree_entries, request)
|
||||||
|
|
|
@ -111,6 +111,20 @@ describe Gitlab::GitalyClient::CommitService do
|
||||||
|
|
||||||
client.tree_entries(repository, revision, path)
|
client.tree_entries(repository, revision, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with UTF-8 params strings' do
|
||||||
|
let(:revision) { "branch\u011F" }
|
||||||
|
let(:path) { "foo/\u011F.txt" }
|
||||||
|
|
||||||
|
it 'handles string encodings correctly' do
|
||||||
|
expect_any_instance_of(Gitaly::CommitService::Stub)
|
||||||
|
.to receive(:get_tree_entries)
|
||||||
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
||||||
|
.and_return([])
|
||||||
|
|
||||||
|
client.tree_entries(repository, revision, path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#find_commit' do
|
describe '#find_commit' do
|
||||||
|
|
Loading…
Reference in New Issue