Commit 2370e5d0 authored by John Cai's avatar John Cai

Update list_last_commits_for_tree response path field to path_bytes

Updates the gitaly client to use path_bytes field instead of the
deprecated path field in list_last_commits_for_tree_response.
Also adds a test to guard against non-utf8 path data
parent f3b3d8b1
1.34.0
1.35.0
\ No newline at end of file
---
title: Client side changes for ListLastCommitsForTree response update
merge_request: 26880
author:
type: fixed
......@@ -174,7 +174,7 @@ module Gitlab
response.each_with_object({}) do |gitaly_response, hsh|
gitaly_response.commits.each do |commit_for_tree|
hsh[commit_for_tree.path] = Gitlab::Git::Commit.new(@repository, commit_for_tree.commit)
hsh[commit_for_tree.path_bytes] = Gitlab::Git::Commit.new(@repository, commit_for_tree.commit)
end
end
end
......
......@@ -217,6 +217,25 @@ describe Repository do
expect(result.size).to eq(0)
end
context 'with a commit with invalid UTF-8 path' do
def create_commit_with_invalid_utf8_path
rugged = rugged_repo(repository)
blob_id = Rugged::Blob.from_buffer(rugged, "some contents")
tree_builder = Rugged::Tree::Builder.new(rugged)
tree_builder.insert({ oid: blob_id, name: "hello\x80world", filemode: 0100644 })
tree_id = tree_builder.write
user = { email: "jcai@gitlab.com", time: Time.now, name: "John Cai" }
Rugged::Commit.create(rugged, message: 'some commit message', parents: [rugged.head.target.oid], tree: tree_id, committer: user, author: user)
end
it 'does not raise an error' do
commit = create_commit_with_invalid_utf8_path
expect { repository.list_last_commits_for_tree(commit, '.', offset: 0) }.not_to raise_error
end
end
end
describe '#last_commit_for_path' 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