Commit 019e881d authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-uri-type-empty' into 'master'

Return nil on empty path

Closes gitaly#1115

See merge request gitlab-org/gitlab-ce!18430
parents e27aa43d e02f1271
...@@ -486,6 +486,8 @@ module Gitlab ...@@ -486,6 +486,8 @@ module Gitlab
end end
def tree_entry(path) def tree_entry(path)
return unless path.present?
@repository.gitaly_migrate(:commit_tree_entry) do |is_migrated| @repository.gitaly_migrate(:commit_tree_entry) do |is_migrated|
if is_migrated if is_migrated
gitaly_tree_entry(path) gitaly_tree_entry(path)
......
...@@ -450,6 +450,11 @@ eos ...@@ -450,6 +450,11 @@ eos
it "returns nil if the path doesn't exists" do it "returns nil if the path doesn't exists" do
expect(commit.uri_type('this/path/doesnt/exist')).to be_nil expect(commit.uri_type('this/path/doesnt/exist')).to be_nil
end end
it 'is nil if the path is nil or empty' do
expect(commit.uri_type(nil)).to be_nil
expect(commit.uri_type("")).to be_nil
end
end end
context 'when Gitaly commit_tree_entry feature is enabled' do context 'when Gitaly commit_tree_entry feature is enabled' 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