lib/gitlab/dangerfiles/category.rb in gitlab-dangerfiles-3.6.7 vs lib/gitlab/dangerfiles/category.rb in gitlab-dangerfiles-3.7.0
- old
+ new
@@ -90,13 +90,48 @@
end
class UX < Category
private
+ def has_particular_capability?(teammate)
+ if labels.any?("Community contribution")
+ can_review_wider_community_contribution?(teammate)
+ else
+ super
+ end
+ end
+
def has_universal_capability?(teammate)
- teammate.projects.each_value.find do |capabilities|
+ # No universal reviewer for community contribution.
+ # If we do, then picking from corresponding group won't be accurate.
+ # After solving the following issue, then we can revisit this:
+ # https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/issues/58
+ return false if labels.any?("Community contribution")
+
+ teammate.projects.each_value.any? do |capabilities|
capabilities.include?(capability)
end
+ end
+
+ def can_review_wider_community_contribution?(teammate)
+ # Pick corresponding group for community contribution
+ # Role can be:
+ # Product Designer, Create:Source Code
+ # Product Designer, Verify:Pipeline Insights, Verify:Runner
+ # Product Designer, Release
+ # Specialty can be:
+ # Source Code
+ # [Growth: Activation, Growth: Expansion]
+ # Runner
+ areas = teammate.role[/Product Designer(?:.*?, (.+))/, 1]&.split(",")
+
+ group_labels = [*teammate.specialty, *areas].map do |field|
+ group = field.strip.sub(/^.+: ?/, "").downcase
+
+ "group::#{group}"
+ end
+
+ (group_labels & labels).any?
end
end
end
end
end