gitlab-dangerfiles 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/README.md +7 -0
- data/lefthook.yml +11 -0
- data/lib/danger/plugins/roulette.rb +34 -2
- data/lib/gitlab/dangerfiles/teammate.rb +14 -5
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17495e36a06253d291cf69ea61fd426ba3541738591873cfdef64e2c9132e8ee
|
4
|
+
data.tar.gz: 5e690f454e356ae1dd7e372ae16d9d8b99b32e1450a48560fe359dfcad20eab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96558f5954dea10cf802d32003045dcdcb6bccaa00c34b4079a654a275ec8dcb980ca84bf8116d87db1e0dc8a5e85a54b07ec05dc2dbcab4b2696e3e1532173
|
7
|
+
data.tar.gz: b112119bfbbff88bb66966bed0e5ee0cd32369b2eae89507e17f9e602a8c0a987bbd423aa1a4ed089479c1d9f6842f523db76e83c887676c9387cbd6da4db3e3
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -215,12 +215,19 @@ Latest documentation can be found at <https://www.rubydoc.info/gems/gitlab-dange
|
|
215
215
|
|
216
216
|
## Development
|
217
217
|
|
218
|
+
### Initial setup
|
219
|
+
|
218
220
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
219
221
|
|
220
222
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
221
223
|
|
222
224
|
To release a new version, update the version number in `version.rb`, and get the MR merged by a maintainer. This will be then be packaged into a gem and pushed to [rubygems.org](https://rubygems.org) by the CI/CD.
|
223
225
|
|
226
|
+
### Activate lefthook locally
|
227
|
+
|
228
|
+
```shell
|
229
|
+
lefthook install
|
230
|
+
```
|
224
231
|
## Contributing
|
225
232
|
|
226
233
|
Bug reports and merge requests are welcome at https://gitlab.com/gitlab-org/gitlab-dangerfiles. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/gitlab-org/gitlab-dangerfiles/blob/master/CODE_OF_CONDUCT.md).
|
data/lefthook.yml
ADDED
@@ -162,12 +162,44 @@ module Danger
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
+
# Spin a reviewer for a particular approval rule
|
166
|
+
#
|
167
|
+
# @param [Hash] rule of approval
|
168
|
+
#
|
169
|
+
# @return [Gitlab::Dangerfiles::Teammate]
|
165
170
|
def spin_for_approver(rule)
|
166
|
-
approvers
|
171
|
+
# This will filter out approvers who are not even reviewers who
|
172
|
+
# don't show up in roulette data we're relying on.
|
173
|
+
# That's why `filter_map` is used.
|
174
|
+
approvers = rule["eligible_approvers"].filter_map do |approver|
|
167
175
|
find_member(approver["username"])
|
168
176
|
end
|
169
177
|
|
170
|
-
spin_for_person(approvers)
|
178
|
+
spin_for_person(approvers) || spin_for_approver_fallback(rule)
|
179
|
+
end
|
180
|
+
|
181
|
+
# It can be possible that we don't have a valid reviewer for approval.
|
182
|
+
# In this case, we sample again without considering:
|
183
|
+
#
|
184
|
+
# * If they're available
|
185
|
+
# * If they're an actual reviewer from roulette data
|
186
|
+
#
|
187
|
+
# We do this because we strictly require an approval from the approvers.
|
188
|
+
#
|
189
|
+
# @param [Hash] rule of approval
|
190
|
+
#
|
191
|
+
# @return [Gitlab::Dangerfiles::Teammate]
|
192
|
+
def spin_for_approver_fallback(rule)
|
193
|
+
fallback_approvers = rule["eligible_approvers"].map do |approver|
|
194
|
+
find_member(approver["username"]) ||
|
195
|
+
Gitlab::Dangerfiles::Teammate.new(approver)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Intentionally not using `spin_for_person` to skip `valid_person?`.
|
199
|
+
# This should strictly return someone so we don't filter anything,
|
200
|
+
# and it's a fallback mechanism which should not happen often that
|
201
|
+
# deserves a complex algorithm.
|
202
|
+
fallback_approvers.sample(random: random)
|
171
203
|
end
|
172
204
|
|
173
205
|
def spin_for_category(project, category, timezone_experiment: false)
|
@@ -10,7 +10,8 @@ module Gitlab
|
|
10
10
|
@options = options
|
11
11
|
@username = options["username"]
|
12
12
|
@name = options["name"]
|
13
|
-
@markdown_name = options["markdown_name"]
|
13
|
+
@markdown_name = options["markdown_name"] ||
|
14
|
+
default_markdown_name(*options.values_at("username", "name"))
|
14
15
|
@role = options["role"]
|
15
16
|
@projects = process_projects(options["projects"])
|
16
17
|
@available = options["available"]
|
@@ -66,7 +67,7 @@ module Gitlab
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def markdown_name(author: nil)
|
69
|
-
"#{@markdown_name}
|
70
|
+
"#{@markdown_name}#{utc_offset_text(author)}"
|
70
71
|
end
|
71
72
|
|
72
73
|
def local_hour
|
@@ -83,6 +84,10 @@ module Gitlab
|
|
83
84
|
|
84
85
|
private
|
85
86
|
|
87
|
+
def default_markdown_name(username, name)
|
88
|
+
"[#{name}](https://gitlab.com/#{username}) (`@#{username}`)"
|
89
|
+
end
|
90
|
+
|
86
91
|
def process_projects(projects)
|
87
92
|
return nil unless projects
|
88
93
|
|
@@ -92,15 +97,19 @@ module Gitlab
|
|
92
97
|
end
|
93
98
|
|
94
99
|
def utc_offset_text(author = nil)
|
100
|
+
return unless tz_offset_hours
|
101
|
+
|
95
102
|
offset_text = if floored_offset_hours >= 0
|
96
103
|
"UTC+#{floored_offset_hours}"
|
97
104
|
else
|
98
105
|
"UTC#{floored_offset_hours}"
|
99
106
|
end
|
100
107
|
|
101
|
-
|
102
|
-
|
103
|
-
|
108
|
+
if author
|
109
|
+
" (#{offset_text}, #{offset_diff_compared_to_author(author)})"
|
110
|
+
else
|
111
|
+
" (#{offset_text})"
|
112
|
+
end
|
104
113
|
end
|
105
114
|
|
106
115
|
def offset_diff_compared_to_author(author)
|
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.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- fixtures/emojis/aliases.json
|
164
164
|
- fixtures/emojis/digests.json
|
165
165
|
- gitlab-dangerfiles.gemspec
|
166
|
+
- lefthook.yml
|
166
167
|
- lib/danger/plugins/changelog.rb
|
167
168
|
- lib/danger/plugins/internal/helper.rb
|
168
169
|
- lib/danger/plugins/roulette.rb
|