Commit ceb0636c authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use roulette for single codebase roulette

parent c90ba127
def new_teammates(usernames)
usernames.map { |u| ::Gitlab::Danger::Teammate.new('username' => u) }
end
def mention_single_codebase_approvers def mention_single_codebase_approvers
frontend_maintainers = %w(@filipa @iamphill) canonical_branch_name =
backend_maintainers = %w(@rspeicher @rymai @yorickpeterse @godfat) roulette.canonical_branch_name(gitlab.mr_json['source_branch'])
random = roulette.new_random(canonical_branch_name)
frontend_maintainers = new_teammates(%w[filipa iamphill])
backend_maintainers = new_teammates(%w[rspeicher rymai yorickpeterse godfat])
rows = [] rows = []
users = []
if gitlab.mr_labels.include?('frontend') if gitlab.mr_labels.include?('frontend')
frontend_maintainer = frontend_maintainers.sample frontend_maintainer =
roulette.spin_for_person(frontend_maintainers, random: random)
rows << "| ~frontend | `#{frontend_maintainer}`" rows << "| ~frontend | #{frontend_maintainer.markdown_name}"
users << frontend_maintainer
end end
if gitlab.mr_labels.include?('backend') if gitlab.mr_labels.include?('backend')
backend_maintainer = backend_maintainers.sample backend_maintainer =
roulette.spin_for_person(backend_maintainers, random: random)
rows << "| ~backend | `#{backend_maintainer}`" rows << "| ~backend | #{backend_maintainer.markdown_name}"
users << backend_maintainer
end end
if rows.empty? if rows.empty?
backup_maintainer = backend_maintainers.sample backup_maintainer = backend_maintainers.sample
rows << "| ~frontend / ~backend | `#{backup_maintainer}`" rows << "| ~frontend / ~backend | #{backup_maintainer.markdown_name}"
users << backup_maintainer
end end
markdown(<<~MARKDOWN.strip) markdown(<<~MARKDOWN.strip)
......
...@@ -6,8 +6,8 @@ module Gitlab ...@@ -6,8 +6,8 @@ module Gitlab
attr_reader :name, :username, :projects attr_reader :name, :username, :projects
def initialize(options = {}) def initialize(options = {})
@name = options['name']
@username = options['username'] @username = options['username']
@name = options['name'] || @username
@projects = options['projects'] @projects = options['projects']
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment