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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 02:10:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 02:10:52 +0300
commite3a5a36fc818cc968eef59817df859eb175fb5b2 (patch)
tree4c8f6321cabd6b7d3c3d0c10389ea977b6204744 /app
parenteb4a3b6ed231e0bda2ae746c895073148a03b1ba (diff)
Add latest changes from gitlab-org/gitlab@15-9-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/models/merge_request.rb5
-rw-r--r--app/models/repository.rb12
2 files changed, 16 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 485ca3a3850..f3488f6ea60 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1478,6 +1478,7 @@ class MergeRequest < ApplicationRecord
def fetch_ref!
target_project.repository.fetch_source_branch!(source_project.repository, source_branch, ref_path)
+ expire_ancestor_cache
end
# Returns the current merge-ref HEAD commit.
@@ -2037,6 +2038,10 @@ class MergeRequest < ApplicationRecord
self.draft = draft?
end
+ def expire_ancestor_cache
+ project.repository.expire_ancestor_cache(target_branch_sha, diff_head_sha)
+ end
+
def missing_report_error(report_type)
{ status: :error, status_reason: "This merge request does not have #{report_type} reports" }
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index d15f2a430fa..f951418c0bf 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -996,7 +996,7 @@ class Repository
def ancestor?(ancestor_id, descendant_id)
return false if ancestor_id.nil? || descendant_id.nil?
- cache_key = "ancestor:#{ancestor_id}:#{descendant_id}"
+ cache_key = ancestor_cache_key(ancestor_id, descendant_id)
request_store_cache.fetch(cache_key) do
cache.fetch(cache_key) do
raw_repository.ancestor?(ancestor_id, descendant_id)
@@ -1004,6 +1004,12 @@ class Repository
end
end
+ def expire_ancestor_cache(ancestor_id, descendant_id)
+ cache_key = ancestor_cache_key(ancestor_id, descendant_id)
+ request_store_cache.expire(cache_key)
+ cache.expire(cache_key)
+ end
+
def clone_as_mirror(url, http_authorization_header: "", resolved_address: "")
import_repository(url, http_authorization_header: http_authorization_header, mirror: true, resolved_address: resolved_address)
end
@@ -1224,6 +1230,10 @@ class Repository
private
+ def ancestor_cache_key(ancestor_id, descendant_id)
+ "ancestor:#{ancestor_id}:#{descendant_id}"
+ end
+
# TODO Genericize finder, later split this on finders by Ref or Oid
# https://gitlab.com/gitlab-org/gitlab/issues/19877
def find_commit(oid_or_ref)