diff options
author | Stan Hu <stanhu@gmail.com> | 2017-10-01 19:45:44 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-10-01 22:14:11 -0700 |
commit | 6188e449dee43a18b9cec1a7bb5a2cd7aa17b6f7 (patch) | |
tree | 96ee8f0098786b9489ee025cdbd28747ad3f0198 /app | |
parent | 6c33fb846683ca9213dadaa79b0f32f482ebc0bf (diff) | |
download | gitlab-ce-6188e449dee43a18b9cec1a7bb5a2cd7aa17b6f7.tar.gz |
Fix pushes to an empty repository not invalidating has_visible_content? cache
`Repository#has_visible_content?` used to rely on the cached count of local branches, but
since it is now an independently cached value it needs to be invalidated on its own.
Closes #38646
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 1f4df50a913..a0f57f1e54d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -34,7 +34,10 @@ class Repository CACHED_METHODS = %i(size commit_count rendered_readme contribution_guide changelog license_blob license_key gitignore koding_yml gitlab_ci_yml branch_names tag_names branch_count - tag_count avatar exists? empty? root_ref).freeze + tag_count avatar exists? empty? root_ref has_visible_content?).freeze + + # Methods that use cache_method but only memoize the value + MEMOIZED_CACHED_METHODS = %i(license empty_repo?).freeze # Certain method caches should be refreshed when certain types of files are # changed. This Hash maps file types (as returned by Gitlab::FileDetector) to @@ -269,7 +272,7 @@ class Repository end def expire_branches_cache - expire_method_caches(%i(branch_names branch_count)) + expire_method_caches(%i(branch_names branch_count has_visible_content?)) @local_branches = nil @branch_exists_memo = nil end @@ -340,7 +343,7 @@ class Repository def expire_emptiness_caches return unless empty? - expire_method_caches(%i(empty?)) + expire_method_caches(%i(empty? has_visible_content?)) end def lookup_cache |