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:
authorPatrick Bajao <ebajao@gitlab.com>2019-08-09 13:09:06 +0300
committerPatrick Bajao <ebajao@gitlab.com>2019-08-09 13:09:06 +0300
commitd96c24d81590dd6da237f131d4c074b70e64e030 (patch)
tree89acd70b24f5256f495fc2ac2bdaeda071cac4b5 /app/workers
parent136c3efe61f2bee4acb9474d6a214a23632988ff (diff)
Invalidate branches cache on PostReceive
Whenever `PostReceive` is enqueued, `UpdateMergeRequestsWorker` is enqueued and `MergeRequests::RefreshService` is called, it'll check if the source branch of each MR asssociated to the push exists or not via `MergeRequest#source_branch_exists?`. The said method will call `Repository#branch_exists?` which is cached in `Rails.cache`. When the cache contains outdated data and the source branch actually exists, the `MergeRequests#RefreshService` job will close associated MRs which is not correct. The fix is to expire the branches cache of the project so we have updated data during the post receive hook which will help in the accuracy of the check if we need to close associated MRs or not.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/post_receive.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index dba7837bd12..0865c2f0e0e 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.branches_exist?
+
post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index|
service_klass =
if Gitlab::Git.tag_ref?(ref)