Class: Gitlab::Dangerfiles::Spinner
- Inherits:
-
Object
- Object
- Gitlab::Dangerfiles::Spinner
- Defined in:
- lib/gitlab/dangerfiles/spinner.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#team_author ⇒ Object
readonly
Returns the value of attribute team_author.
Instance Method Summary collapse
-
#initialize(project:, author:, team_author: nil, labels: [], categories: [], random: Random.new, ux_fallback_wider_community_reviewer: nil) ⇒ Spinner
constructor
A new instance of Spinner.
-
#spin ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#spin_for_approver(rule) ⇒ Gitlab::Dangerfiles::Teammate
Spin a reviewer for a particular approval rule.
Constructor Details
#initialize(project:, author:, team_author: nil, labels: [], categories: [], random: Random.new, ux_fallback_wider_community_reviewer: nil) ⇒ Spinner
Returns a new instance of Spinner.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 13 def initialize( project:, author:, team_author: nil, labels: [], categories: [], random: Random.new, ux_fallback_wider_community_reviewer: nil) @project = project @author = @team_author = @labels = labels @categories = categories.reject do |category| import_and_integrate_reject_category?(category) end @random = random @ux_fallback_wider_community_reviewer = ux_fallback_wider_community_reviewer end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
11 12 13 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 11 def @author end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
11 12 13 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 11 def categories @categories end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
11 12 13 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 11 def labels @labels end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
11 12 13 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 11 def project @project end |
#team_author ⇒ Object (readonly)
Returns the value of attribute team_author.
11 12 13 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 11 def @team_author end |
Instance Method Details
#spin ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 28 def spin spins = categories.sort_by(&:to_s).map do |category| spin_for_category(category) end backend_spin = spins.find { |spin| spin.category == :backend } frontend_spin = spins.find { |spin| spin.category == :frontend } spins.each do |spin| case spin.category when :qa spin.optional_role = :maintainer if categories.size > 1 && when :test spin.optional_role = :maintainer if spin.no_reviewer? # Fetch an already picked backend reviewer, or pick one otherwise spin.reviewer = backend_spin&.reviewer || spin_for_category(:backend).reviewer end when :tooling if spin.no_maintainer? # Fetch an already picked backend maintainer, or pick one otherwise spin.maintainer = backend_spin&.maintainer || spin_for_category(:backend).maintainer end when :ci_template # rubocop:disable Lint/DuplicateBranch -- bug? if spin.no_maintainer? # Fetch an already picked backend maintainer, or pick one otherwise spin.maintainer = backend_spin&.maintainer || spin_for_category(:backend).maintainer end when :analytics_instrumentation spin.optional_role = :maintainer if spin.no_maintainer? # Fetch an already picked maintainer, or pick one otherwise spin.maintainer = backend_spin&.maintainer || frontend_spin&.maintainer || spin_for_category(:backend).maintainer end when :import_integrate_be, :import_integrate_fe spin.optional_role = :maintainer when :ux spin.optional_role = :maintainer # We want at least a UX reviewer who can review any wider community # contribution even without a team designer. We assign this to Pedro. spin.reviewer = ux_fallback_wider_community_reviewer if labels.include?("Community contribution") && spin.no_reviewer? && spin.no_maintainer? end end spins end |
#spin_for_approver(rule) ⇒ Gitlab::Dangerfiles::Teammate
Spin a reviewer for a particular approval rule
88 89 90 91 92 93 94 95 |
# File 'lib/gitlab/dangerfiles/spinner.rb', line 88 def spin_for_approver(rule) approvers = rule["eligible_approvers"].filter_map do |approver| Gitlab::Dangerfiles::Teammate.find_member( approver["username"], project: project) end spin_for_person(approvers) || spin_for_approver_fallback(rule) end |