Commit e02f1271 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Return nil on empty path

The execution path wasn't clear from the error, but either way this is a
fix.

Closes gitlab-org/gitaly#1115
parent 25cb70ba
...@@ -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