gitlab-dangerfiles 3.6.3 → 3.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +8 -65
- data/README.md +4 -0
- data/lib/danger/plugins/changelog.rb +34 -7
- data/lib/danger/plugins/internal/helper.rb +20 -2
- data/lib/danger/plugins/roulette.rb +7 -3
- data/lib/danger/rules/simple_roulette/Dangerfile +6 -7
- data/lib/gitlab/dangerfiles/category.rb +8 -2
- data/lib/gitlab/dangerfiles/teammate.rb +3 -5
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- data/lib/gitlab/dangerfiles/weightage/reviewers.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a126428046a10355043b190fbf80e70dec6c01a6e9d8778770455a8c30d748c
|
4
|
+
data.tar.gz: 65060b4bd492f3887c22fb6a09fba51c5262f4680e45c364a1ec775a1968a844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca9f2ea3ebf80b9fa8f0f7ce19a01309acc2e120c8661fd618f59b0e48bf638098826257050be4af32cc9553c797dd3af1cd7a1784d234f27c240ec407a6ada
|
7
|
+
data.tar.gz: 14ba2e996756f8beab4e046e87a1d6739285cdf55dbdcf357bdc6768f8a1ff7101797e6c5baf7fce90aa28dfbe3f41c28f3b386a4351090003162368271432cc
|
data/.rubocop.yml
CHANGED
@@ -32,9 +32,14 @@ Style/HashSyntax:
|
|
32
32
|
Style/StringLiterals:
|
33
33
|
EnforcedStyle: double_quotes
|
34
34
|
|
35
|
+
# To respect rufo formatting
|
35
36
|
Style/TrailingCommaInHashLiteral:
|
36
37
|
EnforcedStyleForMultiline: consistent_comma
|
37
38
|
|
39
|
+
# To respect rufo formatting
|
40
|
+
Layout/MultilineOperationIndentation:
|
41
|
+
Enabled: false
|
42
|
+
|
38
43
|
# Was problematic, and not included in the .rubocop_todo.yml
|
39
44
|
GitlabSecurity/PublicSend:
|
40
45
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2023-01-12 11:28:46 UTC using RuboCop version 1.36.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -86,18 +86,6 @@ Layout/LineEndStringConcatenationIndentation:
|
|
86
86
|
Exclude:
|
87
87
|
- 'lib/gitlab/dangerfiles/commit_linter.rb'
|
88
88
|
|
89
|
-
# Offense count: 7
|
90
|
-
# This cop supports safe autocorrection (--autocorrect).
|
91
|
-
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
92
|
-
# SupportedStyles: aligned, indented
|
93
|
-
Layout/MultilineOperationIndentation:
|
94
|
-
Exclude:
|
95
|
-
- 'lib/danger/plugins/changelog.rb'
|
96
|
-
- 'lib/gitlab/dangerfiles/commit_linter.rb'
|
97
|
-
- 'lib/gitlab/dangerfiles/emoji_checker.rb'
|
98
|
-
- 'lib/gitlab/dangerfiles/teammate.rb'
|
99
|
-
- 'spec/danger/plugins/roulette_spec.rb'
|
100
|
-
|
101
89
|
# Offense count: 1
|
102
90
|
# This cop supports safe autocorrection (--autocorrect).
|
103
91
|
Layout/RescueEnsureAlignment:
|
@@ -157,21 +145,6 @@ Lint/RedundantDirGlobSort:
|
|
157
145
|
- 'spec/gitlab/dangerfiles_spec.rb'
|
158
146
|
- 'spec/spec_helper.rb'
|
159
147
|
|
160
|
-
# Offense count: 1
|
161
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
162
|
-
Metrics/AbcSize:
|
163
|
-
Max: 67
|
164
|
-
|
165
|
-
# Offense count: 1
|
166
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
167
|
-
Metrics/CyclomaticComplexity:
|
168
|
-
Max: 31
|
169
|
-
|
170
|
-
# Offense count: 1
|
171
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
172
|
-
Metrics/PerceivedComplexity:
|
173
|
-
Max: 26
|
174
|
-
|
175
148
|
# Offense count: 1
|
176
149
|
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
177
150
|
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
@@ -238,7 +211,7 @@ RSpec/EmptyLineAfterLetBlock:
|
|
238
211
|
Exclude:
|
239
212
|
- 'spec/danger/plugins/internal/helper_spec.rb'
|
240
213
|
|
241
|
-
# Offense count:
|
214
|
+
# Offense count: 7
|
242
215
|
RSpec/ExpectInHook:
|
243
216
|
Exclude:
|
244
217
|
- 'spec/danger/plugins/internal/helper_spec.rb'
|
@@ -267,7 +240,7 @@ RSpec/LetBeforeExamples:
|
|
267
240
|
- 'spec/danger/plugins/internal/helper_spec.rb'
|
268
241
|
- 'spec/danger/plugins/roulette_spec.rb'
|
269
242
|
|
270
|
-
# Offense count:
|
243
|
+
# Offense count: 51
|
271
244
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
272
245
|
# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
|
273
246
|
# SupportedStyles: inflected, explicit
|
@@ -282,7 +255,7 @@ RSpec/RepeatedExampleGroupDescription:
|
|
282
255
|
Exclude:
|
283
256
|
- 'spec/gitlab/dangerfiles/commit_linter_spec.rb'
|
284
257
|
|
285
|
-
# Offense count:
|
258
|
+
# Offense count: 33
|
286
259
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
287
260
|
RSpec/VerifiedDoubles:
|
288
261
|
Exclude:
|
@@ -362,7 +335,7 @@ Style/IfInsideElse:
|
|
362
335
|
Exclude:
|
363
336
|
- 'lib/danger/rules/commit_messages/Dangerfile'
|
364
337
|
|
365
|
-
# Offense count:
|
338
|
+
# Offense count: 22
|
366
339
|
# This cop supports safe autocorrection (--autocorrect).
|
367
340
|
Style/IfUnlessModifier:
|
368
341
|
Exclude:
|
@@ -403,11 +376,6 @@ Style/NumericPredicate:
|
|
403
376
|
- 'lib/danger/plugins/roulette.rb'
|
404
377
|
- 'lib/gitlab/dangerfiles/teammate.rb'
|
405
378
|
|
406
|
-
# Offense count: 1
|
407
|
-
Style/OptionalArguments:
|
408
|
-
Exclude:
|
409
|
-
- 'lib/danger/rules/simple_roulette/Dangerfile'
|
410
|
-
|
411
379
|
# Offense count: 8
|
412
380
|
# This cop supports safe autocorrection (--autocorrect).
|
413
381
|
# Configuration parameters: PreferredDelimiters.
|
@@ -420,7 +388,7 @@ Style/PercentLiteralDelimiters:
|
|
420
388
|
- 'lib/gitlab/dangerfiles/tasks/main.rake'
|
421
389
|
- 'spec/danger/plugins/internal/helper_spec.rb'
|
422
390
|
|
423
|
-
# Offense count:
|
391
|
+
# Offense count: 4
|
424
392
|
# This cop supports safe autocorrection (--autocorrect).
|
425
393
|
# Configuration parameters: .
|
426
394
|
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
|
@@ -444,12 +412,6 @@ Style/RedundantFreeze:
|
|
444
412
|
- 'lib/gitlab/dangerfiles/emoji_checker.rb'
|
445
413
|
- 'lib/gitlab/dangerfiles/title_linting.rb'
|
446
414
|
|
447
|
-
# Offense count: 1
|
448
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
449
|
-
Style/RedundantInterpolation:
|
450
|
-
Exclude:
|
451
|
-
- 'lib/gitlab/dangerfiles/teammate.rb'
|
452
|
-
|
453
415
|
# Offense count: 4
|
454
416
|
# This cop supports safe autocorrection (--autocorrect).
|
455
417
|
Style/RedundantRegexpEscape:
|
@@ -521,7 +483,7 @@ Style/StringConcatenation:
|
|
521
483
|
- 'spec/gitlab/dangerfiles/commit_linter_spec.rb'
|
522
484
|
- 'spec/gitlab/merge_request_linter_spec.rb'
|
523
485
|
|
524
|
-
# Offense count:
|
486
|
+
# Offense count: 7
|
525
487
|
# This cop supports safe autocorrection (--autocorrect).
|
526
488
|
# Configuration parameters: EnforcedStyle.
|
527
489
|
# SupportedStyles: single_quotes, double_quotes
|
@@ -549,7 +511,7 @@ Style/TrailingCommaInArguments:
|
|
549
511
|
Exclude:
|
550
512
|
- 'spec/danger/plugins/roulette_spec.rb'
|
551
513
|
|
552
|
-
# Offense count:
|
514
|
+
# Offense count: 24
|
553
515
|
# This cop supports safe autocorrection (--autocorrect).
|
554
516
|
# Configuration parameters: EnforcedStyleForMultiline.
|
555
517
|
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
@@ -565,22 +527,3 @@ Style/TrailingCommaInArrayLiteral:
|
|
565
527
|
- 'spec/gitlab/dangerfiles/title_linting_spec.rb'
|
566
528
|
- 'spec/gitlab/dangerfiles/weightage/maintainers_spec.rb'
|
567
529
|
- 'spec/gitlab/dangerfiles/weightage/reviewers_spec.rb'
|
568
|
-
|
569
|
-
# Offense count: 29
|
570
|
-
# This cop supports safe autocorrection (--autocorrect).
|
571
|
-
# Configuration parameters: EnforcedStyleForMultiline.
|
572
|
-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
573
|
-
Style/TrailingCommaInHashLiteral:
|
574
|
-
Exclude:
|
575
|
-
- 'lib/danger/plugins/changelog.rb'
|
576
|
-
- 'lib/danger/plugins/internal/helper.rb'
|
577
|
-
- 'lib/danger/plugins/roulette.rb'
|
578
|
-
- 'lib/gitlab/dangerfiles/base_linter.rb'
|
579
|
-
- 'lib/gitlab/dangerfiles/commit_linter.rb'
|
580
|
-
- 'lib/gitlab/dangerfiles/spec_helper.rb'
|
581
|
-
- 'lib/gitlab/dangerfiles/type_label_guesser.rb'
|
582
|
-
- 'spec/danger/plugins/internal/helper_spec.rb'
|
583
|
-
- 'spec/danger/plugins/roulette_spec.rb'
|
584
|
-
- 'spec/gitlab/dangerfiles/config_spec.rb'
|
585
|
-
- 'spec/gitlab/dangerfiles/teammate_spec.rb'
|
586
|
-
- 'spec/gitlab/dangerfiles_spec.rb'
|
data/README.md
CHANGED
@@ -128,8 +128,12 @@ project. To use it in your project, perform the following steps:
|
|
128
128
|
see how to set it up.
|
129
129
|
1. When using the default roulette, use `import_defaults` or import it manually when setting
|
130
130
|
up the gitlab-dangerfiles instance:
|
131
|
+
|
131
132
|
```ruby
|
133
|
+
require 'gitlab-dangerfiles'
|
134
|
+
|
132
135
|
Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
|
136
|
+
dangerfiles.import_plugins
|
133
137
|
dangerfiles.import_dangerfiles(only: %w[simple_roulette])
|
134
138
|
end
|
135
139
|
```
|
@@ -15,6 +15,11 @@ module Danger
|
|
15
15
|
CHANGELOG_EE_TRAILER_REGEX = /^EE: true$/.freeze
|
16
16
|
CHANGELOG_MODIFIED_URL_TEXT = "**CHANGELOG.md was edited.** Please remove the additions and follow the [changelog guidelines](https://docs.gitlab.com/ee/development/changelog.html).\n\n"
|
17
17
|
CHANGELOG_MISSING_URL_TEXT = "**[CHANGELOG missing](https://docs.gitlab.com/ee/development/changelog.html)**:\n\n"
|
18
|
+
IF_REVERT_MR_TEXT = <<~MARKDOWN
|
19
|
+
If you are in a revert MR, consider using the revert MR template to add labels to skip changelog checks ([docs](https://docs.gitlab.com/ee/development/pipelines#revert-mrs)).
|
20
|
+
|
21
|
+
If this is reverting something in the current milestone, we don't need to add a changelog. In this case, we can skip changelog checks by adding `~"regression:*"` label, and re-run the danger job (there is a link at the bottom of this comment).
|
22
|
+
MARKDOWN
|
18
23
|
|
19
24
|
OPTIONAL_CHANGELOG_MESSAGE = {
|
20
25
|
local: "If this merge request [doesn't need a CHANGELOG entry](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry), feel free to ignore this message.",
|
@@ -110,25 +115,47 @@ module Danger
|
|
110
115
|
valid_changelog_commits.map(&:category)
|
111
116
|
end
|
112
117
|
|
113
|
-
# rubocop:disable Style/SignalException
|
114
118
|
def check!
|
115
|
-
if
|
116
|
-
|
117
|
-
|
119
|
+
return if revert_in_current_milestone?
|
120
|
+
|
121
|
+
critical_checks
|
122
|
+
regular_checks
|
123
|
+
changelog_categories_checks
|
124
|
+
end
|
125
|
+
|
126
|
+
def revert_in_current_milestone?
|
127
|
+
return false unless helper.revert_mr?
|
128
|
+
|
129
|
+
current_regression_label = "regression:#{helper.current_milestone.title}"
|
130
|
+
|
131
|
+
helper.mr_labels.any?(current_regression_label)
|
132
|
+
end
|
118
133
|
|
134
|
+
def critical_checks
|
135
|
+
check_result = ChangelogCheckResult.empty
|
136
|
+
|
137
|
+
check_result.error(modified_text) if git.modified_files.include?("CHANGELOG.md")
|
138
|
+
|
139
|
+
# Help the user to apply the correct labels to skip this danger check in case it's a revert MR
|
140
|
+
check_result.warning(IF_REVERT_MR_TEXT)
|
141
|
+
|
142
|
+
add_danger_messages(check_result)
|
143
|
+
end
|
144
|
+
|
145
|
+
def regular_checks
|
119
146
|
if exist?
|
120
147
|
add_danger_messages(check_changelog_path)
|
121
148
|
elsif required?
|
122
|
-
required_texts.each { |_, text| fail(text) } # rubocop:disable Lint/UnreachableLoop
|
149
|
+
required_texts.each { |_, text| fail(text) } # rubocop:disable Lint/UnreachableLoop, Style/SignalException
|
123
150
|
elsif optional?
|
124
151
|
message optional_text
|
125
152
|
end
|
153
|
+
end
|
126
154
|
|
155
|
+
def changelog_categories_checks
|
127
156
|
check_changelog_commit_categories
|
128
157
|
end
|
129
158
|
|
130
|
-
# rubocop:enable Style/SignalException
|
131
|
-
|
132
159
|
# rubocop:disable Style/SignalException
|
133
160
|
def add_danger_messages(check_result)
|
134
161
|
check_result.errors.each { |error| fail(error) } # rubocop:disable Lint/UnreachableLoop
|
@@ -12,9 +12,11 @@ module Danger
|
|
12
12
|
# Common helper functions for our danger scripts.
|
13
13
|
class Helper < Danger::Plugin
|
14
14
|
RELEASE_TOOLS_BOT = "gitlab-release-tools-bot"
|
15
|
+
# rubocop:disable Style/HashSyntax
|
15
16
|
CATEGORY_LABELS = {
|
16
17
|
docs: "~documentation", # Docs are reviewed along DevOps stages, so don't need roulette for now.
|
17
|
-
none: "",
|
18
|
+
none: "None",
|
19
|
+
nil => "N/A",
|
18
20
|
qa: "~QA",
|
19
21
|
ux: "~UX",
|
20
22
|
codeowners: '~"Code Owners"',
|
@@ -29,6 +31,9 @@ module Danger
|
|
29
31
|
"Authentication and Authorization": '~"group::authentication and authorization"',
|
30
32
|
Compliance: '~"group::compliance"',
|
31
33
|
}.freeze
|
34
|
+
# rubocop:enable Style/HashSyntax
|
35
|
+
|
36
|
+
GITLAB_ORG_GROUP_ID = "9970"
|
32
37
|
|
33
38
|
# Allows to set specific rule's configuration by passing a block.
|
34
39
|
#
|
@@ -228,7 +233,7 @@ module Danger
|
|
228
233
|
found
|
229
234
|
end
|
230
235
|
|
231
|
-
Array(categories || :
|
236
|
+
Array(categories || :none)
|
232
237
|
end
|
233
238
|
|
234
239
|
# @param category [Symbol] A category.
|
@@ -317,6 +322,13 @@ module Danger
|
|
317
322
|
)
|
318
323
|
end
|
319
324
|
|
325
|
+
# @return [Boolean] +false+ when not in the CI context, and returns +true+ if the MR title starts with Revert or revert
|
326
|
+
def revert_mr?
|
327
|
+
return false unless ci?
|
328
|
+
|
329
|
+
mr_title.start_with?(/[Rr]evert/)
|
330
|
+
end
|
331
|
+
|
320
332
|
# @return [Boolean] +true+ when not in the CI context, and whether the MR is set to be squashed otherwise.
|
321
333
|
def squash_mr?
|
322
334
|
return true unless ci?
|
@@ -432,6 +444,12 @@ module Danger
|
|
432
444
|
@labels_to_add ||= []
|
433
445
|
end
|
434
446
|
|
447
|
+
def current_milestone
|
448
|
+
@current_milestone ||= gitlab_helper.api.group_milestones(GITLAB_ORG_GROUP_ID, state: "active")
|
449
|
+
.select { |m| m.title.match?(/\A\d+\.\d+\z/) && !m.expired && m.start_date && m.due_date }
|
450
|
+
.min_by(&:start_date)
|
451
|
+
end
|
452
|
+
|
435
453
|
private
|
436
454
|
|
437
455
|
# @return [Danger::RequestSources::GitLab, nil] the +gitlab+ helper, or +nil+ when it's not available.
|
@@ -48,9 +48,10 @@ module Danger
|
|
48
48
|
# @param timezone_experiment [Boolean] Whether to select reviewers based in timezone or not.
|
49
49
|
#
|
50
50
|
# @return [Array<Spin>]
|
51
|
-
|
51
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
52
|
+
def spin(project = nil, categories = [:none], timezone_experiment: false)
|
52
53
|
project = (project || config_project_name).downcase
|
53
|
-
categories = categories.map { |category| category&.downcase }
|
54
|
+
categories = categories.map { |category| category&.downcase || :none }
|
54
55
|
categories.reject! { |category| integrations_reject_category?(category, project) }
|
55
56
|
|
56
57
|
spins = categories.sort_by(&:to_s).map do |category|
|
@@ -67,7 +68,8 @@ module Danger
|
|
67
68
|
case spin.category
|
68
69
|
when :qa
|
69
70
|
# MR includes QA changes, but also other changes, and author isn't an SET
|
70
|
-
if categories.size > 1 &&
|
71
|
+
if categories.size > 1 &&
|
72
|
+
!(team_mr_author && team_mr_author.capabilities(project).any? { |capability| capability.end_with?("qa") })
|
71
73
|
spin.optional_role = :maintainer
|
72
74
|
end
|
73
75
|
when :test
|
@@ -104,6 +106,8 @@ module Danger
|
|
104
106
|
spins
|
105
107
|
end
|
106
108
|
|
109
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
110
|
+
|
107
111
|
def required_approvals
|
108
112
|
approval_rules = helper.mr_approval_state["rules"]
|
109
113
|
|
@@ -60,12 +60,12 @@ def note_for_spin_role(spin, role)
|
|
60
60
|
spin.public_send(role)&.markdown_name(author: roulette.team_mr_author)
|
61
61
|
end
|
62
62
|
|
63
|
-
def markdown_row_for_spins(category
|
63
|
+
def markdown_row_for_spins(category, spins_array, show_category_column:)
|
64
64
|
reviewer_note = note_for_spins_role(spins_array, :reviewer)
|
65
65
|
maintainer_note = note_for_spins_role(spins_array, :maintainer)
|
66
66
|
|
67
67
|
row = +"| #{reviewer_note} | #{maintainer_note} |"
|
68
|
-
row.prepend("| #{helper.label_for_category(category)} ") if
|
68
|
+
row.prepend("| #{helper.label_for_category(category)} ") if show_category_column
|
69
69
|
row
|
70
70
|
end
|
71
71
|
|
@@ -73,7 +73,7 @@ changes = helper.changes_by_category
|
|
73
73
|
|
74
74
|
# Replicating label based categories from:
|
75
75
|
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/danger/roulette/Dangerfile
|
76
|
-
categories = Set.new(changes.keys
|
76
|
+
categories = Set.new(changes.keys)
|
77
77
|
|
78
78
|
# Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries)
|
79
79
|
categories << :database if helper.mr_labels.include?('database')
|
@@ -91,15 +91,14 @@ categories.delete(:product_intelligence) if helper.mr_labels.include?("growth ex
|
|
91
91
|
categories.subtract(helper.config.disabled_roulette_categories)
|
92
92
|
|
93
93
|
if changes.any?
|
94
|
-
|
95
|
-
categories = [nil] unless has_categories
|
94
|
+
show_category_column = categories.size > 1 || categories.first != :none
|
96
95
|
random_roulette_spins = roulette.spin(nil, categories)
|
97
96
|
|
98
97
|
rows = random_roulette_spins.map do |spin|
|
99
|
-
markdown_row_for_spins(spin.category, [spin],
|
98
|
+
markdown_row_for_spins(spin.category, [spin], show_category_column: show_category_column)
|
100
99
|
end
|
101
100
|
|
102
|
-
table_header =
|
101
|
+
table_header = show_category_column ? TABLE_HEADER_WITH_CATEGORIES : TABLE_HEADER_WITHOUT_CATEGORIES
|
103
102
|
|
104
103
|
markdown(MESSAGE)
|
105
104
|
markdown(TABLE_MARKDOWN + table_header + rows.join("\n")) unless rows.empty?
|
@@ -11,6 +11,7 @@ module Gitlab
|
|
11
11
|
|
12
12
|
def self.name_to_class
|
13
13
|
@name_to_class ||= {
|
14
|
+
none: None,
|
14
15
|
test: Test,
|
15
16
|
tooling: Tooling,
|
16
17
|
integrations_be: IntegrationsBE,
|
@@ -35,8 +36,13 @@ module Gitlab
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def capability
|
38
|
-
# name
|
39
|
-
|
39
|
+
@capability ||= "#{kind} #{name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
class None < Category
|
43
|
+
def capability
|
44
|
+
@capability ||= kind.to_s
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
class Test < Category
|
@@ -5,7 +5,8 @@ require_relative "category"
|
|
5
5
|
module Gitlab
|
6
6
|
module Dangerfiles
|
7
7
|
class Teammate
|
8
|
-
attr_reader :options, :username, :name, :role, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours
|
8
|
+
attr_reader :options, :username, :name, :role, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours,
|
9
|
+
:only_maintainer_reviews
|
9
10
|
|
10
11
|
# The options data are produced by https://gitlab.com/gitlab-org/gitlab-roulette/-/blob/master/lib/team_member.rb
|
11
12
|
def initialize(options = {})
|
@@ -20,6 +21,7 @@ module Gitlab
|
|
20
21
|
@hungry = options["hungry"]
|
21
22
|
@reduced_capacity = options["reduced_capacity"]
|
22
23
|
@tz_offset_hours = options["tz_offset_hours"]
|
24
|
+
@only_maintainer_reviews = options["only_maintainer_reviews"]
|
23
25
|
end
|
24
26
|
|
25
27
|
def to_h
|
@@ -40,10 +42,6 @@ module Gitlab
|
|
40
42
|
projects&.has_key?(name)
|
41
43
|
end
|
42
44
|
|
43
|
-
def any_capability?(project, category)
|
44
|
-
capabilities(project).any? { |capability| capability.end_with?(category.to_s) }
|
45
|
-
end
|
46
|
-
|
47
45
|
def reviewer?(project, category, labels)
|
48
46
|
has_capability?(project, category, :reviewer, labels)
|
49
47
|
end
|
@@ -33,6 +33,7 @@ module Gitlab
|
|
33
33
|
# https://gitlab.com/gitlab-org/gitlab/issues/26723
|
34
34
|
|
35
35
|
remove_traintainers_from_reviewers!
|
36
|
+
remove_maintainer_only_from_reviewers!
|
36
37
|
|
37
38
|
weighted_reviewers + weighted_traintainers
|
38
39
|
end
|
@@ -49,6 +50,11 @@ module Gitlab
|
|
49
50
|
reviewers.reject! { |reviewer| traintainers.include?(reviewer) }
|
50
51
|
end
|
51
52
|
|
53
|
+
def remove_maintainer_only_from_reviewers!
|
54
|
+
# Using a maintainer-only reviewer emoji, team members can ensure they only get maintainer reviews
|
55
|
+
reviewers.reject! { |reviewer| reviewer&.only_maintainer_reviews }
|
56
|
+
end
|
57
|
+
|
52
58
|
def weighted_reviewers
|
53
59
|
reviewers.each_with_object([]) do |reviewer, total_reviewers|
|
54
60
|
add_weighted_reviewer(total_reviewers, reviewer, DEFAULT_REVIEWER_WEIGHT)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-dangerfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|