summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-06-27 13:35:13 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-06-27 13:35:13 +0000
commit7e2188a18e63251fd3038ef803a6dfc37e867fe5 (patch)
treef6133d124ca0d6e53bbc3840094ae10e6215edb3
parentd6588577fb69f67b55e61e522c2b4802ec4bf41c (diff)
downloadgitlab-ce-7e2188a18e63251fd3038ef803a6dfc37e867fe5.tar.gz
Change GetRawChanges RPC to use bytes
-rw-r--r--changelogs/unreleased/po-raw-changes-encoding.yml5
-rw-r--r--lib/gitlab/git/raw_diff_change.rb4
-rw-r--r--spec/models/repository_spec.rb13
-rw-r--r--spec/support/helpers/test_env.rb3
4 files changed, 22 insertions, 3 deletions
diff --git a/changelogs/unreleased/po-raw-changes-encoding.yml b/changelogs/unreleased/po-raw-changes-encoding.yml
new file mode 100644
index 00000000000..051d18f50c7
--- /dev/null
+++ b/changelogs/unreleased/po-raw-changes-encoding.yml
@@ -0,0 +1,5 @@
+---
+title: Expect bytes from Gitaly RPC GetRawChanges
+merge_request: 28164
+author:
+type: fixed
diff --git a/lib/gitlab/git/raw_diff_change.rb b/lib/gitlab/git/raw_diff_change.rb
index e1002af40f6..9a41f04a4db 100644
--- a/lib/gitlab/git/raw_diff_change.rb
+++ b/lib/gitlab/git/raw_diff_change.rb
@@ -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)
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index c5ab7e57272..0bd17dbacd7 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -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'
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index 77f22d9dd24..e63099d89b7 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -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