Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-06-13 10:54:31 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-06-13 10:54:31 +0300
commit10ea97505f134ec4b43c93071a02d1498f2e5fc3 (patch)
tree54f4d8c072412d26f983c9d6f10acb799eb8785b /lib
parent738f55a0376f86a7e52fb4b76f3e22bd5da514c2 (diff)
parentcef127e10778a21756c00c4226592f32f15a6c1f (diff)
Merge branch '61157-reviewer-roulette-shouldn-t-include-the-author-as-a-possibility' into 'master'
Review roulette excludes mr_author Closes #61157 See merge request gitlab-org/gitlab-ce!28886
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)