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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
211886dd
Commit
211886dd
authored
Jun 01, 2020
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ~test and ~QA maintainer review optional
parent
c6158f0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
20 deletions
+34
-20
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+34
-20
No files found.
danger/roulette/Dangerfile
View file @
211886dd
...
...
@@ -36,10 +36,10 @@ Please consider creating a merge request to
for them.
MARKDOWN
NO_REVIEWER
=
'No reviewer available'
.
freeze
NO
_MAINTAINER
=
'No maintainer
available'
.
freeze
OPTIONAL_REVIEW_TEMPLATE
=
"%{role} review is optional for %{category}"
.
freeze
NO
T_AVAILABLE_TEMPLATE
=
'No %{role}
available'
.
freeze
Spin
=
Struct
.
new
(
:reviewer
,
:maintainer
)
Spin
=
Struct
.
new
(
:reviewer
,
:maintainer
,
:optional
)
def
spin_role_for_category
(
team
,
role
,
project
,
category
)
team
.
select
do
|
member
|
...
...
@@ -61,11 +61,26 @@ def spin_for_category(team, project, category, branch_name)
reviewer
=
roulette
.
spin_for_person
(
reviewers
+
traintainers
+
traintainers
,
random:
random
)
maintainer
=
roulette
.
spin_for_person
(
maintainers
,
random:
random
)
Spin
.
new
(
reviewer
,
maintainer
)
Spin
.
new
(
reviewer
,
maintainer
).
tap
do
|
spin
|
if
[
:qa
,
:test
].
include?
(
category
)
spin
.
optional
=
:maintainer
end
end
end
def
note_for_category_role
(
category
,
role
,
spin
)
if
spin
.
optional
==
role
return
OPTIONAL_REVIEW_TEMPLATE
%
{
role:
role
.
capitalize
,
category:
helper
.
label_for_category
(
category
)
}
end
spin
.
public_send
(
role
)
&
.
markdown_name
||
NOT_AVAILABLE_TEMPLATE
%
{
role:
role
}
# rubocop:disable GitlabSecurity/PublicSend
end
def
markdown_row_for_category
(
category
,
reviewer
,
maintainer
)
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
||
NO_REVIEWER
}
|
#{
maintainer
&
.
markdown_name
||
NO_MAINTAINER
}
|"
def
markdown_row_for_category
(
category
,
spin
)
reviewer_note
=
note_for_category_role
(
category
,
:reviewer
,
spin
)
maintainer_note
=
note_for_category_role
(
category
,
:maintainer
,
spin
)
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer_note
}
|
#{
maintainer_note
}
|"
end
changes
=
helper
.
changes_by_category
...
...
@@ -78,44 +93,43 @@ categories = changes.keys - [:unknown]
categories
<<
:database
if
gitlab
.
mr_labels
.
include?
(
'database'
)
&&
!
categories
.
include?
(
:database
)
if
changes
.
any?
# Strip leading and trailing CE/EE markers
canonical_branch_name
=
roulette
.
canonical_branch_name
(
gitlab
.
mr_json
[
'source_branch'
])
project
=
helper
.
project_name
team
=
begin
roulette
.
project_team
(
helper
.
project_name
)
roulette
.
project_team
(
project
)
rescue
=>
err
warn
(
"Reviewer roulette failed to load team data:
#{
err
.
message
}
"
)
[]
end
project
=
helper
.
project_name
unknown
=
changes
.
fetch
(
:unknown
,
[])
# Strip leading and trailing CE/EE markers
canonical_branch_name
=
roulette
.
canonical_branch_name
(
gitlab
.
mr_json
[
'source_branch'
])
spin_per_category
=
categories
.
each_with_object
({})
do
|
category
,
memo
|
memo
[
category
]
=
spin_for_category
(
team
,
project
,
category
,
canonical_branch_name
)
end
rows
=
spin_per_category
.
map
do
|
category
,
spin
|
reviewer
=
spin
.
reviewer
maintainer
=
spin
.
maintainer
case
category
when
:test
if
reviewer
.
nil?
if
spin
.
reviewer
.
nil?
# Fetch an already picked backend reviewer, or pick one otherwise
reviewer
=
spin_per_category
[
:backend
]
&
.
reviewer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
reviewer
spin
.
reviewer
=
spin_per_category
[
:backend
]
&
.
reviewer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
reviewer
end
when
:engineering_productivity
if
maintainer
.
nil?
if
spin
.
maintainer
.
nil?
# Fetch an already picked backend maintainer, or pick one otherwise
maintainer
=
spin_per_category
[
:backend
]
&
.
maintainer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
maintainer
spin
.
maintainer
=
spin_per_category
[
:backend
]
&
.
maintainer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
maintainer
end
end
markdown_row_for_category
(
category
,
reviewer
,
maintainer
)
markdown_row_for_category
(
category
,
spin
)
end
unknown
=
changes
.
fetch
(
:unknown
,
[])
markdown
(
MESSAGE
)
markdown
(
CATEGORY_TABLE_HEADER
+
rows
.
join
(
"
\n
"
))
unless
rows
.
empty?
markdown
(
UNKNOWN_FILES_MESSAGE
+
helper
.
markdown_list
(
unknown
))
unless
unknown
.
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