Sha256: 69f4342dfe1547610d4a333f422e6f0b0a1ff1f63b7b3c69c33e9ba4b4ae2bf7

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

PROJECT_NAME = helper.config.project_name

MESSAGE = <<MARKDOWN
## Reviewer roulette

Changes that require review have been detected! A merge request is normally
reviewed by both a reviewer and a maintainer in its primary category and by a
maintainer in all other categories.
MARKDOWN

TABLE_MARKDOWN = <<MARKDOWN

To spread load more evenly across eligible reviewers, Danger has picked a candidate for each
review slot. Feel free to
[override these selections](https://about.gitlab.com/handbook/engineering/projects/##{PROJECT_NAME})
if you think someone else would be better-suited.

To read more on how to use the reviewer roulette, please take a look at the
[Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).

Once you've decided who will review this merge request, mention them as you
normally would! Danger does not automatically notify them for you.

| Reviewer | Maintainer |
| -------- | ---------- |
MARKDOWN

def note_for_spins_role(spins, role)
  spins.each do |spin|
    note = note_for_spin_role(spin, role)

    return note if note
  end

  'No %{role} available' % { role: role }
end

def note_for_spin_role(spin, role)
  spin.public_send(role)&.markdown_name(author: roulette.team_mr_author)
end

def markdown_row_for_spins(spins_array)
  reviewer_note = note_for_spins_role(spins_array, :reviewer)
  maintainer_note = note_for_spins_role(spins_array, :maintainer)

  "#{reviewer_note} | #{maintainer_note} |"
end

if helper.changes.any?
  random_roulette_spins = roulette.spin

  rows = random_roulette_spins.map do |spin|
    markdown_row_for_spins([spin])
  end

  markdown(MESSAGE)
  markdown(TABLE_MARKDOWN + rows.join("\n")) unless rows.empty?
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitlab-dangerfiles-2.6.1 lib/danger/rules/simple_roulette/Dangerfile
gitlab-dangerfiles-2.6.0 lib/danger/rules/simple_roulette/Dangerfile