summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2019-05-29 23:15:09 +0800
committerLin Jen-Shin <godfat@godfat.org>2019-05-30 19:24:28 +0800
commitceb0636cbe600a27a9ce8e5d66c796647af3c84b (patch)
tree3ce30128b408330afcb12b3f08e419df38f80623 /danger
parentc90ba127bf8cdd4ccac9692b6c96fa746314cd55 (diff)
downloadgitlab-ce-ceb0636cbe600a27a9ce8e5d66c796647af3c84b.tar.gz
Use roulette for single codebase rouletteextract-danger-roulette
Diffstat (limited to 'danger')
-rw-r--r--danger/single_codebase/Dangerfile29
1 files changed, 18 insertions, 11 deletions
diff --git a/danger/single_codebase/Dangerfile b/danger/single_codebase/Dangerfile
index a5938cd6783..d1f538bec7f 100644
--- a/danger/single_codebase/Dangerfile
+++ b/danger/single_codebase/Dangerfile
@@ -1,29 +1,36 @@
+def new_teammates(usernames)
+ usernames.map { |u| ::Gitlab::Danger::Teammate.new('username' => u) }
+end
+
def mention_single_codebase_approvers
- frontend_maintainers = %w(@filipa @iamphill)
- backend_maintainers = %w(@rspeicher @rymai @yorickpeterse @godfat)
+ canonical_branch_name =
+ 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 = []
- users = []
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}`"
- users << frontend_maintainer
+ rows << "| ~frontend | #{frontend_maintainer.markdown_name}"
end
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}`"
- users << backend_maintainer
+ rows << "| ~backend | #{backend_maintainer.markdown_name}"
end
if rows.empty?
backup_maintainer = backend_maintainers.sample
- rows << "| ~frontend / ~backend | `#{backup_maintainer}`"
- users << backup_maintainer
+ rows << "| ~frontend / ~backend | #{backup_maintainer.markdown_name}"
end
markdown(<<~MARKDOWN.strip)