diff options
author | Stan Hu <stanhu@gmail.com> | 2018-01-16 23:47:17 +0300 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2018-01-17 19:10:25 +0300 |
commit | 672cb71072fd007b76e2aa10c7a4562e479224d7 (patch) | |
tree | da4ec941aa9bfb62453d9e84682331e17c095a0d /spec | |
parent | f8d905d228f3ee4e140f033f5ebf0e35bb71b96f (diff) |
Merge branch 'jej/lfs-rev-list-handles-non-utf-paths-41627' into 'master'
Prevent RevList failing on non utf8 paths
Closes #41627
See merge request gitlab-org/gitlab-ce!16440
(cherry picked from commit 3228ac06a019c9126b965ff32e354d10011a4f76)
c4dd7b82 Prevent RevList failing on non utf8 paths
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/rev_list_spec.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/spec/lib/gitlab/git/rev_list_spec.rb b/spec/lib/gitlab/git/rev_list_spec.rb index eaf74951b0e..90fbef9d248 100644 --- a/spec/lib/gitlab/git/rev_list_spec.rb +++ b/spec/lib/gitlab/git/rev_list_spec.rb @@ -39,7 +39,7 @@ describe Gitlab::Git::RevList do ] expect(rev_list).to receive(:popen).with(*params) do |*_, lazy_block:| - lazy_block.call(output.split("\n").lazy) + lazy_block.call(output.lines.lazy.map(&:chomp)) end end @@ -64,6 +64,15 @@ describe Gitlab::Git::RevList do expect(rev_list.new_objects(require_path: true)).to eq(%w[sha2]) end + it 'can handle non utf-8 paths' do + non_utf_char = [0x89].pack("c*").force_encoding("UTF-8") + stub_lazy_popen_rev_list('newrev', '--not', '--all', '--objects', output: "sha2 πå†h/†ø/ƒîlé#{non_utf_char}\nsha1") + + rev_list.new_objects(require_path: true) do |object_ids| + expect(object_ids.force).to eq(%w[sha2]) + end + end + it 'can yield a lazy enumerator' do stub_lazy_popen_rev_list('newrev', '--not', '--all', '--objects', output: "sha1\nsha2") |