From 9a99d8e49dc07faaaa2fae436423e11dab5a7d7e Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 8 Feb 2016 12:50:55 +0100 Subject: Cache various Repository Git operations This caches the output of the following methods: * Repository#empty? * Repository#has_visible_content? * Repository#root_ref The cache for Repository#has_visible_content? is flushed whenever a commit is pushed to a new branch or an existing branch is removed. The cache for Repository#root_ref is only flushed whenever a user changes the default branch of a project. The cache for Repository#empty? is never explicitly flushed as there's no need for it. --- app/models/project.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models/project.rb') diff --git a/app/models/project.rb b/app/models/project.rb index 043f08b9a13..f11c6d7c6be 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -790,6 +790,8 @@ class Project < ActiveRecord::Base def change_head(branch) # Cached divergent commit counts are based on repository head repository.expire_branch_cache + repository.expire_root_ref_cache + gitlab_shell.update_repository_head(self.path_with_namespace, branch) reload_default_branch end -- cgit v1.2.1