diff options
author | Robert Speicher <robert@gitlab.com> | 2018-01-12 17:00:59 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-01-12 17:00:59 +0000 |
commit | b35b57a179b8d9e1f5e0d9201178f0ba3b56f921 (patch) | |
tree | bcf0871d3346f5370f6e9f79b1794c58f4531580 /app/models/project.rb | |
parent | 6438a1afa7f260da3d7de85c4986042bdf56c84e (diff) | |
parent | a68ba4887719ab5aa6a244c47835580d8a85eb13 (diff) | |
download | gitlab-ce-b35b57a179b8d9e1f5e0d9201178f0ba3b56f921.tar.gz |
Merge branch '41731-predicate-memoization' into 'master'
Introduce PredicateMemoization cop
Closes #41731
See merge request gitlab-org/gitlab-ce!16329
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 11 |
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) |