summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2019-08-16 19:53:57 +0000
committerDouwe Maan <douwe@gitlab.com>2019-08-16 19:53:57 +0000
commitb0a230daedd99b5a7b41ddf544c66a6ed57adefc (patch)
tree3dbeb5f11039722f520694041e6e161d15b628f0 /lib
parentb3145bc976836f4c28a2f97a57e40b9f315aa3a4 (diff)
parentf14647fdae4a07c3c59665576b70f847ab866c58 (diff)
downloadgitlab-ce-b0a230daedd99b5a7b41ddf544c66a6ed57adefc.tar.gz
Merge branch 'sh-post-receive-cache-clear-once' into 'master'
Expire project caches once per push instead of once per ref Closes #52046 See merge request gitlab-org/gitlab-ce!31876
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git_post_receive.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/gitlab/git_post_receive.rb b/lib/gitlab/git_post_receive.rb
index 24d752b8a4b..2a8bcd015a8 100644
--- a/lib/gitlab/git_post_receive.rb
+++ b/lib/gitlab/git_post_receive.rb
@@ -39,6 +39,17 @@ module Gitlab
end
end
+ def includes_default_branch?
+ # If the branch doesn't have a default branch yet, we presume the
+ # first branch pushed will be the default.
+ return true unless project.default_branch.present?
+
+ enum_for(:changes_refs).any? do |_oldrev, _newrev, ref|
+ Gitlab::Git.branch_ref?(ref) &&
+ Gitlab::Git.branch_name(ref) == project.default_branch
+ end
+ end
+
private
def deserialize_changes(changes)