gitlab-dangerfiles 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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: 4.6.0
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-06 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -213,6 +213,7 @@ files:
213
213
  - CONTRIBUTING.md
214
214
  - Dangerfile
215
215
  - Gemfile
216
+ - Gemfile.lock
216
217
  - Guardfile
217
218
  - LICENSE.txt
218
219
  - README.md
@@ -238,14 +239,17 @@ files:
238
239
  - lib/gitlab-dangerfiles.rb
239
240
  - lib/gitlab/Dangerfile
240
241
  - lib/gitlab/dangerfiles.rb
242
+ - lib/gitlab/dangerfiles/approval.rb
241
243
  - lib/gitlab/dangerfiles/base_linter.rb
242
- - lib/gitlab/dangerfiles/category.rb
244
+ - lib/gitlab/dangerfiles/capability.rb
243
245
  - lib/gitlab/dangerfiles/changes.rb
244
246
  - lib/gitlab/dangerfiles/commit_linter.rb
245
247
  - lib/gitlab/dangerfiles/config.rb
246
248
  - lib/gitlab/dangerfiles/emoji_checker.rb
247
249
  - lib/gitlab/dangerfiles/merge_request_linter.rb
248
250
  - lib/gitlab/dangerfiles/spec_helper.rb
251
+ - lib/gitlab/dangerfiles/spin.rb
252
+ - lib/gitlab/dangerfiles/spinner.rb
249
253
  - lib/gitlab/dangerfiles/task_loader.rb
250
254
  - lib/gitlab/dangerfiles/tasks/main.rake
251
255
  - lib/gitlab/dangerfiles/teammate.rb
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gitlab
4
- module Dangerfiles
5
- CategoryStruct = Struct.new(:name, :project, :kind, :labels, keyword_init: true)
6
-
7
- class Category < CategoryStruct
8
- def self.for(name, **arguments)
9
- (name_to_class[name] || self).new(name: name, **arguments)
10
- end
11
-
12
- def self.name_to_class
13
- @name_to_class ||= {
14
- none: None,
15
- test: Test,
16
- tooling: Tooling,
17
- import_integrate_be: ImportIntegrateBE,
18
- import_integrate_fe: ImportIntegrateFE,
19
- ux: UX,
20
- }.freeze
21
- end
22
- private_class_method :name_to_class
23
-
24
- def has_capability?(teammate)
25
- teammate.capabilities(project).include?(capability)
26
- end
27
-
28
- private
29
-
30
- def capability
31
- @capability ||= "#{kind} #{name}"
32
- end
33
-
34
- class None < Category
35
- def capability
36
- @capability ||= kind.to_s
37
- end
38
- end
39
-
40
- class Test < Category
41
- def has_capability?(teammate)
42
- return false if kind != :reviewer
43
-
44
- area = teammate.role[/Software Engineer in Test(?:.*?, (\w+))/, 1]
45
-
46
- !!area && labels.any?("devops::#{area.downcase}")
47
- end
48
- end
49
-
50
- class Tooling < Category
51
- def has_capability?(teammate)
52
- if super
53
- true
54
- elsif %i[trainee_maintainer maintainer].include?(kind)
55
- false
56
- else # fallback to backend reviewer
57
- teammate.capabilities(project).include?("#{kind} backend")
58
- end
59
- end
60
- end
61
-
62
- class ImportIntegrateBE < Category
63
- def has_capability?(teammate)
64
- kind == :reviewer &&
65
- teammate.role.match?(/Backend Engineer.+Manage:Import and Integrate/)
66
- end
67
- end
68
-
69
- class ImportIntegrateFE < Category
70
- def has_capability?(teammate)
71
- kind == :reviewer &&
72
- teammate.role.match?(/Frontend Engineer.+Manage:Import and Integrate/)
73
- end
74
- end
75
-
76
- class UX < Category
77
- def has_capability?(teammate)
78
- super &&
79
-
80
- if labels.any?("Community contribution")
81
- # We want the designer for the team to review the wider community
82
- # contribution because they're more familiar with that area.
83
- the_designer_for_the_team?(teammate)
84
- else
85
- # We don't want the designer for the team to review merge
86
- # requests for the same team which is designed by themselves.
87
- # So they can only review if they're not the designer for the team.
88
- !the_designer_for_the_team?(teammate)
89
- end
90
- end
91
-
92
- private
93
-
94
- def the_designer_for_the_team?(teammate)
95
- # Pick corresponding group for community contribution
96
- # Specialty can be:
97
- # Source Code
98
- # [Growth: Activation, Growth: Expansion]
99
- # Runner
100
- group_labels = Array(teammate.specialty).map do |field|
101
- group = field.strip.sub(/^.+: ?/, "").downcase
102
-
103
- "group::#{group}"
104
- end
105
-
106
- (group_labels & labels).any?
107
- end
108
- end
109
- end
110
- end
111
- end