Merge branch 'po-raw-changes-encoding' into 'master'

Change GetRawChanges RPC to use bytes

Closes gitaly#1470

See merge request gitlab-org/gitlab-ce!28164
This commit is contained in:
Douglas Barbosa Alexandre 2019-06-27 13:35:14 +00:00
commit ccf3caf4ed
4 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
title: Expect bytes from Gitaly RPC GetRawChanges
merge_request: 28164
author:
type: fixed

View File

@ -11,8 +11,8 @@ module Gitlab
if raw_change.is_a?(Gitaly::GetRawChangesResponse::RawChange)
@blob_id = raw_change.blob_id
@blob_size = raw_change.size
@old_path = raw_change.old_path.presence
@new_path = raw_change.new_path.presence
@old_path = raw_change.old_path_bytes.presence
@new_path = raw_change.new_path_bytes.presence
@operation = raw_change.operation&.downcase || :unknown
else
parse(raw_change)

View File

@ -844,6 +844,19 @@ describe Repository do
end
end
describe '#get_raw_changes' do
context `with non-UTF8 bytes in paths` do
let(:old_rev) { 'd0888d297eadcd7a345427915c309413b1231e65' }
let(:new_rev) { '19950f03c765f7ac8723a73a0599764095f52fc0' }
let(:changes) { repository.raw_changes_between(old_rev, new_rev) }
it 'returns the changes' do
expect { changes }.not_to raise_error
expect(changes.first.new_path.bytes).to eq("hello\x80world".bytes)
end
end
end
describe '#create_ref' do
it 'redirects the call to write_ref' do
ref, ref_path = '1', '2'

View File

@ -64,7 +64,8 @@ module TestEnv
'with-codeowners' => '219560e',
'submodule_inside_folder' => 'b491b92',
'png-lfs' => 'fe42f41',
'sha-starting-with-large-number' => '8426165'
'sha-starting-with-large-number' => '8426165',
'invalid-utf8-diff-paths' => '99e4853'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily