summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-04-18 08:20:21 +0000
committerDouwe Maan <douwe@gitlab.com>2018-04-18 08:20:21 +0000
commit019e881d448f05a253bdd6a5dcd26c42885770c4 (patch)
treeed62c6e1011b26ca618399f244380fb84069c251
parente27aa43d7a57c841f7a56ab93aa2c6821f45d183 (diff)
parente02f1271f5784fe7c17a9efae8612999e1e62ee3 (diff)
downloadgitlab-ce-019e881d448f05a253bdd6a5dcd26c42885770c4.tar.gz
Merge branch 'zj-uri-type-empty' into 'master'
Return nil on empty path Closes gitaly#1115 See merge request gitlab-org/gitlab-ce!18430
-rw-r--r--lib/gitlab/git/commit.rb2
-rw-r--r--spec/models/commit_spec.rb5
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