Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-02-09 16:59:11 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-02-09 19:17:56 +0300
commit2ce0d06389c3eb7ac9a2b81f9fd339e7e56512bb (patch)
tree67f6a2c4880cb910d2cdfcbdd4a2e0c5ac2b6600 /app/services
parent643c61867cc99f626d58798a5365e7573f90b176 (diff)
Smarter flushing of branch statistics caches
Instead of flushing the behind/ahead counts for all branches upon every push we now only flush the cache of branches that actually need to have these statistics recalculated. There are now basically 2 scenarios and their effects: 1. A user pushes a commit to the default branch, this results in the cache being flushed for all branches. 2. A user pushes to a non default branch, this results in _only_ the cache for that branch being flushed. The existing code (Repository#expire_cache) remains backwards compatible with the previous behaviour, the new behaviour is only applied when a branch name is passed as an argument. This ensures that when for example a project is deleted the cache for all branches is flushed.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/git_push_service.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 0f31756797d..e3bf14966c8 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -18,7 +18,9 @@ class GitPushService
def execute(project, user, oldrev, newrev, ref)
@project, @user = project, user
- project.repository.expire_cache
+ branch_name = Gitlab::Git.ref_name(ref)
+
+ project.repository.expire_cache(branch_name)
if push_remove_branch?(ref, newrev)
project.repository.expire_has_visible_content_cache
@@ -33,7 +35,6 @@ class GitPushService
@push_commits = project.repository.commits(newrev)
# Ensure HEAD points to the default branch in case it is not master
- branch_name = Gitlab::Git.ref_name(ref)
project.change_head(branch_name)
# Set protection on the default branch if configured