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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /lib/gitlab/reference_extractor.rb
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r--lib/gitlab/reference_extractor.rb25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index 547549361be..f914123a94d 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -6,16 +6,11 @@ module Gitlab
REFERABLES = %i(user issue label milestone mentioned_user mentioned_group mentioned_project
merge_request snippet commit commit_range directly_addressed_user epic iteration vulnerability).freeze
attr_accessor :project, :current_user, :author
- # This counter is increased by a number of references filtered out by
- # banzai reference exctractor. Note that this counter is stateful and
- # not idempotent and is increased whenever you call `references`.
- attr_reader :stateful_not_visible_counter
def initialize(project, current_user = nil)
@project = project
@current_user = current_user
@references = {}
- @stateful_not_visible_counter = 0
super()
end
@@ -26,14 +21,19 @@ module Gitlab
def references(type, ids_only: false)
refs = super(type, project, current_user, ids_only: ids_only)
- @stateful_not_visible_counter += refs[:not_visible].count
+ update_visible_nodes_set(refs[:nodes], refs[:visible_nodes])
refs[:visible]
end
+ # this method is stateful, it tracks if all nodes from `references`
+ # calls are visible or not
+ def all_visible?
+ not_visible_nodes.empty?
+ end
+
def reset_memoized_values
@references = {}
- @stateful_not_visible_counter = 0
super()
end
@@ -76,5 +76,16 @@ module Gitlab
@pattern = Regexp.union(patterns.compact)
end
+
+ private
+
+ def update_visible_nodes_set(all, visible)
+ not_visible_nodes.merge(all)
+ not_visible_nodes.subtract(visible)
+ end
+
+ def not_visible_nodes
+ @not_visible_nodes ||= Set.new
+ end
end
end