summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-01-10 01:30:04 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-01-12 17:54:55 +0800
commit4f00a05152c105814f17a5f582d493435de96747 (patch)
tree76eab649b7c832afb47ad3e37ead6eb7a4bdaa93 /app/models/project.rb
parent3fde958f36fa9c3bfa30ed1f73108e0640722926 (diff)
downloadgitlab-ce-4f00a05152c105814f17a5f582d493435de96747.tar.gz
Introduce PredicateMemoization cop and fix offenses
with StrongMemoize
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 029f2da2e4e..7ab7df4fdcd 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -20,6 +20,7 @@ class Project < ActiveRecord::Base
include GroupDescendant
include Gitlab::SQL::Pattern
include DeploymentPlatform
+ include ::Gitlab::Utils::StrongMemoize
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
@@ -993,9 +994,13 @@ class Project < ActiveRecord::Base
end
def repo_exists?
- @repo_exists ||= repository.exists?
- rescue
- @repo_exists = false
+ strong_memoize(:repo_exists) do
+ begin
+ repository.exists?
+ rescue
+ false
+ end
+ end
end
def root_ref?(branch)