summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2019-05-30 12:50:40 +0200
committerJacopo <beschi.jacopo@gmail.com>2019-06-12 21:32:35 +0200
commitcef127e10778a21756c00c4226592f32f15a6c1f (patch)
treea3d1500d26ec126dd5c6921475727e2972bb8eb4 /lib
parent8ade1f8758efa687e67c0c29e8d67217c31c9e0f (diff)
downloadgitlab-ce-cef127e10778a21756c00c4226592f32f15a6c1f.tar.gz
Excludes MR author from gitlab_ui and single_codebase Review roulette results.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/danger/helper.rb4
-rw-r--r--lib/gitlab/danger/roulette.rb20
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb
index 7a0fb419f8e..1ecf4a12db7 100644
--- a/lib/gitlab/danger/helper.rb
+++ b/lib/gitlab/danger/helper.rb
@@ -124,6 +124,10 @@ module Gitlab
%r{\.(md|txt)\z} => :none, # To reinstate roulette for documentation, set to `:docs`.
%r{\.js\z} => :frontend
}.freeze
+
+ def new_teammates(usernames)
+ usernames.map { |u| Gitlab::Danger::Teammate.new('username' => u) }
+ end
end
end
end
diff --git a/lib/gitlab/danger/roulette.rb b/lib/gitlab/danger/roulette.rb
index 062eda38ee4..25de0a87c9d 100644
--- a/lib/gitlab/danger/roulette.rb
+++ b/lib/gitlab/danger/roulette.rb
@@ -45,21 +45,19 @@ module Gitlab
# Known issue: If someone is rejected due to OOO, and then becomes not OOO, the
# selection will change on next spin
def spin_for_person(people, random:)
- person = nil
- people = people.dup
-
- people.size.times do
- person = people.sample(random: random)
-
- break person unless out_of_office?(person)
+ people.shuffle(random: random)
+ .find(&method(:valid_person?))
+ end
- people -= [person]
- end
+ private
- person
+ def valid_person?(person)
+ !mr_author?(person) && !out_of_office?(person)
end
- private
+ def mr_author?(person)
+ person.username == gitlab.mr_author
+ end
def out_of_office?(person)
username = CGI.escape(person.username)