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 /lib/gitlab/git_post_receive.rb
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 'lib/gitlab/git_post_receive.rb')
-rw-r--r--lib/gitlab/git_post_receive.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/git_post_receive.rb b/lib/gitlab/git_post_receive.rb
index d98b85fecc4..307ec8b2cfb 100644
--- a/lib/gitlab/git_post_receive.rb
+++ b/lib/gitlab/git_post_receive.rb
@@ -27,6 +27,14 @@ module Gitlab
end
end
+ def branches_exist?
+ changes_refs do |_oldrev, _newrev, ref|
+ return true if Gitlab::Git.branch_ref?(ref) # rubocop:disable Cop/AvoidReturnFromBlocks
+ end
+
+ false
+ end
+
private
def deserialize_changes(changes)