From 9cc15172deaa4582c5fd956cc163539041d018b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Fri, 6 Oct 2017 20:47:06 -0300 Subject: [PATCH] Clean hierarchy of calls between models and Gitalb::Git for blob search --- app/models/repository.rb | 4 +--- lib/gitlab/git/repository.rb | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index bf526ca1762..579aa2b2f05 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -468,9 +468,7 @@ class Repository end def blob_at(sha, path) - unless Gitlab::Git.blank_ref?(sha) - Blob.decorate(Gitlab::Git::Blob.find(self, sha, path), project) - end + Blob.decorate(raw_repository.blob_at(sha, path), project) rescue Gitlab::Git::Repository::NoRepository nil end diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index a6b2d189f18..b705c92d686 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1092,6 +1092,10 @@ module Gitlab popen(args, @path).last.zero? end + def blob_at(sha, path) + Gitlab::Git::Blob.find(self, sha, path) unless Gitlab::Git.blank_ref?(sha) + end + def gitaly_repository Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository) end