BigW Consortium Gitlab

Commit 8e263c98 by Douwe Maan

Merge branch '39363-fix-ls-files-encoding' into 'master'

Fix encoding issue with Repository.ls_files Closes #39363 See merge request gitlab-org/gitlab-ce!15113
parents e54dd249 d6066870
......@@ -18,7 +18,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :commit_service, :list_files, request)
response.flat_map do |msg|
msg.paths.map { |d| d.dup.force_encoding(Encoding::UTF_8) }
msg.paths.map { |d| EncodingHelper.encode!(d.dup) }
end
end
......
......@@ -1163,6 +1163,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
describe "#ls_files" do
let(:master_file_paths) { repository.ls_files("master") }
let(:utf8_file_paths) { repository.ls_files("ls-files-utf8") }
let(:not_existed_branch) { repository.ls_files("not_existed_branch") }
it "read every file paths of master branch" do
......@@ -1184,6 +1185,10 @@ describe Gitlab::Git::Repository, seed_helper: true do
it "returns empty array when not existed branch" do
expect(not_existed_branch.length).to equal(0)
end
it "returns valid utf-8 data" do
expect(utf8_file_paths.map { |file| file.force_encoding('utf-8') }).to all(be_valid_encoding)
end
end
describe "#copy_gitattributes" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment