diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2019-08-13 18:41:25 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2019-08-13 18:41:25 +0300 |
commit | 3702ab7317533896c7455357dd6643181666f22b (patch) | |
tree | cd1a6ff66d7ac489922da4a6a38df6057f5cf172 /app | |
parent | 530f7f6f0f3172d5712beb0a00c861ffa6935bd7 (diff) | |
parent | afe867921cab046a34bc463840c6e9f5d51f1f70 (diff) |
Merge branch '65803-invalidate-branches-cache-on-refresh' into 'master'
Only expire branch cache once per push
See merge request gitlab-org/gitlab-ce!31653
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 8 | ||||
-rw-r--r-- | app/services/git/branch_hooks_service.rb | 4 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index a89f573e3d6..58abfaef801 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -460,8 +460,8 @@ class Repository end # Runs code after a new branch has been created. - def after_create_branch - expire_branches_cache + def after_create_branch(expire_cache: true) + expire_branches_cache if expire_cache repository_event(:push_branch) end @@ -474,8 +474,8 @@ class Repository end # Runs code after an existing branch has been removed. - def after_remove_branch - expire_branches_cache + def after_remove_branch(expire_cache: true) + expire_branches_cache if expire_cache end def method_missing(msg, *args, &block) diff --git a/app/services/git/branch_hooks_service.rb b/app/services/git/branch_hooks_service.rb index c41f445c3c4..431a5aedf2e 100644 --- a/app/services/git/branch_hooks_service.rb +++ b/app/services/git/branch_hooks_service.rb @@ -63,7 +63,7 @@ module Git end def branch_create_hooks - project.repository.after_create_branch + project.repository.after_create_branch(expire_cache: false) project.after_create_default_branch if default_branch? end @@ -78,7 +78,7 @@ module Git end def branch_remove_hooks - project.repository.after_remove_branch + project.repository.after_remove_branch(expire_cache: false) end # Schedules processing of commit messages diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index dba7837bd12..d8dfbc0faf7 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -42,6 +42,9 @@ class PostReceive user = identify_user(post_received) return false unless user + # Expire the branches cache so we have updated data for this push + post_received.project.repository.expire_branches_cache if post_received.includes_branches? + post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index| service_klass = if Gitlab::Git.tag_ref?(ref) |