Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
dfc9d0b6
Commit
dfc9d0b6
authored
Apr 25, 2019
by
Michael Kozono
Committed by
Brett Walker
Apr 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude reviewers with OOO in status
parent
7ae2107d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
8 deletions
+34
-8
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+34
-8
No files found.
danger/roulette/Dangerfile
View file @
dfc9d0b6
...
@@ -31,26 +31,52 @@ Please consider creating a merge request to
...
@@ -31,26 +31,52 @@ Please consider creating a merge request to
for them.
for them.
MARKDOWN
MARKDOWN
def
spin
(
team
,
project
,
category
,
branch_name
)
def
spin
_for_category
(
team
,
project
,
category
,
branch_name
)
rng
=
Random
.
new
(
Digest
::
MD5
.
hexdigest
(
branch_name
).
to_i
(
16
))
rng
=
Random
.
new
(
Digest
::
MD5
.
hexdigest
(
branch_name
).
to_i
(
16
))
reviewers
=
team
.
select
{
|
member
|
member
.
reviewer?
(
project
,
category
)
}
reviewers
=
team
.
select
{
|
member
|
member
.
reviewer?
(
project
,
category
)
}
traintainers
=
team
.
select
{
|
member
|
member
.
traintainer?
(
project
,
category
)
}
traintainers
=
team
.
select
{
|
member
|
member
.
traintainer?
(
project
,
category
)
}
maintainers
=
team
.
select
{
|
member
|
member
.
maintainer?
(
project
,
category
)
}
maintainers
=
team
.
select
{
|
member
|
member
.
maintainer?
(
project
,
category
)
}
# TODO: filter out people who are currently not in the office
# https://gitlab.com/gitlab-org/gitlab-ce/issues/57652
#
# TODO: take CODEOWNERS into account?
# TODO: take CODEOWNERS into account?
# https://gitlab.com/gitlab-org/gitlab-ce/issues/57653
# https://gitlab.com/gitlab-org/gitlab-ce/issues/57653
# Make traintainers have triple the chance to be picked as a reviewer
# Make traintainers have triple the chance to be picked as a reviewer
reviewer
=
(
reviewers
+
traintainers
+
traintainers
).
sample
(
random:
rng
)
reviewer
=
spin_for_person
(
reviewers
+
traintainers
+
traintainers
,
random:
rng
)
maintainer
=
maintainers
.
sample
(
random:
rng
)
maintainer
=
spin_for_person
(
maintainers
,
random:
rng
)
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
}
|
#{
maintainer
&
.
markdown_name
}
|"
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
}
|
#{
maintainer
&
.
markdown_name
}
|"
end
end
# 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
)
return
person
unless
out_of_office?
(
person
)
people
-=
[
person
]
end
end
def
out_of_office?
(
person
)
username
=
CGI
.
escape
(
person
.
username
)
api_endpoint
=
"https://gitlab.com/api/v4/users/
#{
username
}
/status"
response
=
HTTParty
.
get
(
api_endpoint
)
# rubocop:disable Gitlab/HTTParty
if
response
.
code
==
200
response
[
"message"
]
&
.
match
(
/OOO/i
)
else
false
# this is no worse than not checking for OOO
end
rescue
false
end
def
build_list
(
items
)
def
build_list
(
items
)
list
=
items
.
map
{
|
filename
|
"* `
#{
filename
}
`"
}.
join
(
"
\n
"
)
list
=
items
.
map
{
|
filename
|
"* `
#{
filename
}
`"
}.
join
(
"
\n
"
)
...
@@ -63,7 +89,7 @@ end
...
@@ -63,7 +89,7 @@ end
changes
=
helper
.
changes_by_category
changes
=
helper
.
changes_by_category
# Ignore any files that are known but uncategoried. Prompt for any unknown files
# Ignore any files that are known but uncategori
z
ed. Prompt for any unknown files
changes
.
delete
(
:none
)
changes
.
delete
(
:none
)
categories
=
changes
.
keys
-
[
:unknown
]
categories
=
changes
.
keys
-
[
:unknown
]
...
@@ -92,7 +118,7 @@ if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_l
...
@@ -92,7 +118,7 @@ if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_l
project
=
helper
.
project_name
project
=
helper
.
project_name
unknown
=
changes
.
fetch
(
:unknown
,
[])
unknown
=
changes
.
fetch
(
:unknown
,
[])
rows
=
categories
.
map
{
|
category
|
spin
(
team
,
project
,
category
,
canonical_branch_name
)
}
rows
=
categories
.
map
{
|
category
|
spin
_for_category
(
team
,
project
,
category
,
canonical_branch_name
)
}
markdown
(
MESSAGE
)
markdown
(
MESSAGE
)
markdown
(
CATEGORY_TABLE_HEADER
+
rows
.
join
(
"
\n
"
))
unless
rows
.
empty?
markdown
(
CATEGORY_TABLE_HEADER
+
rows
.
join
(
"
\n
"
))
unless
rows
.
empty?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment