diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-17 16:30:16 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-17 16:30:18 +0200 |
commit | e02f1271f5784fe7c17a9efae8612999e1e62ee3 (patch) | |
tree | 168b4a215a51cb980c8e6c34da51a052f75f6a7c | |
parent | 25cb70ba6087d86343a127df88394fbe97b381b1 (diff) | |
download | gitlab-ce-e02f1271f5784fe7c17a9efae8612999e1e62ee3.tar.gz |
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
-rw-r--r-- | lib/gitlab/git/commit.rb | 2 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 0fb82441bf8..fabcd46c8e9 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -486,6 +486,8 @@ module Gitlab end def tree_entry(path) + return unless path.present? + @repository.gitaly_migrate(:commit_tree_entry) do |is_migrated| if is_migrated gitaly_tree_entry(path) diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 959383ff0b7..4e6b037a720 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -450,6 +450,11 @@ eos it "returns nil if the path doesn't exists" do expect(commit.uri_type('this/path/doesnt/exist')).to be_nil 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 context 'when Gitaly commit_tree_entry feature is enabled' do |