summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2018-02-16 15:15:32 +0100
committerStan Hu <stanhu@gmail.com>2018-02-16 22:28:08 -0800
commit8b727fea81b19f12366894c4a4b981250c549833 (patch)
tree89ed1215f3f80907a33ed2479ceefad788e91470 /app
parentb236348388c46c0550ec6844df35ec2689c4060b (diff)
downloadgitlab-ce-8b727fea81b19f12366894c4a4b981250c549833.tar.gz
Don't cache a nil repository root ref to prevent caching issuesdm-dont-cache-nil-root-ref
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 4f754b11da4..299a3f32a85 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -492,12 +492,8 @@ class Repository
end
def root_ref
- if raw_repository
- raw_repository.root_ref
- else
- # When the repo does not exist we raise this error so no data is cached.
- raise Gitlab::Git::Repository::NoRepository
- end
+ # When the repo does not exist, or there is no root ref, we raise this error so no data is cached.
+ raw_repository&.root_ref or raise Gitlab::Git::Repository::NoRepository # rubocop:disable Style/AndOr
end
cache_method :root_ref