Merge branch 'jc-update-list-last-commits' into 'master'

Client side changes for ListLastCommitsForTree response update

See merge request gitlab-org/gitlab-ce!26880
This commit is contained in:
Lin Jen-Shin 2019-04-25 06:29:48 +00:00
commit 3fe07ce7d1
4 changed files with 26 additions and 2 deletions

View file

@ -1 +1 @@
1.34.0
1.35.0

View file

@ -0,0 +1,5 @@
---
title: Client side changes for ListLastCommitsForTree response update
merge_request: 26880
author:
type: fixed

View file

@ -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

View file

@ -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