gitlab-triage 1.25.0 → 1.27.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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -1
- data/README.md +28 -4
- data/lib/gitlab/triage/engine.rb +11 -12
- data/lib/gitlab/triage/graphql_queries/query_builder.rb +6 -2
- data/lib/gitlab/triage/option_parser.rb +3 -0
- data/lib/gitlab/triage/resource/issue.rb +16 -0
- data/lib/gitlab/triage/rest_api_network.rb +1 -2
- data/lib/gitlab/triage/version.rb +1 -1
- data/support/.gitlab-ci.example.yml +1 -1
- 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: 6668ca8a79611f5e39d317807cb604d7fb32320120283c9996a9784515523bf5
|
4
|
+
data.tar.gz: d6211b78036d039e89a75da4f93bbfa07c44b73ffd16f331ae1bfb5cc901cc9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf0a6406e2a2b6f6cc6b7436831b3b95be04bbf1174c70d3fc5d4a0e24d4e8ccddcd1837864bc8e336fb1c5a0dc947c8a37716d74b31f35e025c4a21bcdb2fda
|
7
|
+
data.tar.gz: 0aa64137299f30fe4f83db4b50475c2b9a15e9730eebbcf5b98d5ce17150a70379f5ae629a87b5d399ce4c74a1712063e222c224ef2e6da29d3016ca48faa35f
|
data/.gitlab-ci.yml
CHANGED
@@ -126,7 +126,7 @@ dry-run:gitlab-triage:
|
|
126
126
|
- gitlab-triage --version
|
127
127
|
- gitlab-triage --help
|
128
128
|
- gitlab-triage --init
|
129
|
-
- gitlab-triage --dry-run --debug --
|
129
|
+
- gitlab-triage --dry-run --debug --source-id $CI_PROJECT_PATH
|
130
130
|
|
131
131
|
# This job requires allows to override the `CI_PROJECT_PATH` variable when triggered.
|
132
132
|
dry-run:custom:
|
data/README.md
CHANGED
@@ -169,7 +169,7 @@ Available condition types:
|
|
169
169
|
- [`milestone` condition](#milestone-condition)
|
170
170
|
- [`iteration` condition](#iteration-condition)
|
171
171
|
- [`state` condition](#state-condition)
|
172
|
-
- [`
|
172
|
+
- [`votes` condition](#votes-condition)
|
173
173
|
- [`labels` condition](#labels-condition)
|
174
174
|
- [`forbidden_labels` condition](#forbidden-labels-condition)
|
175
175
|
- [`no_additional_labels` condition](#no-additional-labels-condition)
|
@@ -182,6 +182,7 @@ Available condition types:
|
|
182
182
|
- [`discussions` condition](#discussions-condition)
|
183
183
|
- [`protected` condition](#protected-condition)
|
184
184
|
- [`ruby` condition](#ruby-condition)
|
185
|
+
- [`reviewer_id` condition](#reviewer-id-condition)
|
185
186
|
|
186
187
|
##### Date condition
|
187
188
|
|
@@ -264,7 +265,7 @@ conditions:
|
|
264
265
|
state: opened
|
265
266
|
```
|
266
267
|
|
267
|
-
#####
|
268
|
+
##### Votes condition
|
268
269
|
|
269
270
|
Accepts a hash of fields.
|
270
271
|
|
@@ -278,7 +279,7 @@ Example:
|
|
278
279
|
|
279
280
|
```yml
|
280
281
|
conditions:
|
281
|
-
|
282
|
+
votes:
|
282
283
|
attribute: upvotes
|
283
284
|
condition: less_than
|
284
285
|
threshold: 10
|
@@ -670,6 +671,19 @@ limits:
|
|
670
671
|
most_recent: 50
|
671
672
|
```
|
672
673
|
|
674
|
+
##### Reviewer id condition
|
675
|
+
|
676
|
+
**This condition is only applicable for merge requests.**
|
677
|
+
|
678
|
+
Accepts the id of a user to filter on. Also accepts `none` or `any`.
|
679
|
+
|
680
|
+
Example:
|
681
|
+
|
682
|
+
```yml
|
683
|
+
conditions:
|
684
|
+
reviewer_id: any
|
685
|
+
```
|
686
|
+
|
673
687
|
#### Actions field
|
674
688
|
|
675
689
|
Used to declare an action to be carried out on a resource if **all** conditions are satisfied.
|
@@ -1195,6 +1209,7 @@ Here's a list of currently available Ruby expression API:
|
|
1195
1209
|
| related_merge_requests | [MergeRequest] | The list of merge requests related to the issue |
|
1196
1210
|
| closed_by | [MergeRequest] | The list of merge requests that close the issue |
|
1197
1211
|
| linked_issues | [LinkedIssue] | The list of issues that are linked to the issue |
|
1212
|
+
| due_date | Date | The due date of the issue. Could be `nil` |
|
1198
1213
|
|
1199
1214
|
##### Methods for `LinkedIssue`
|
1200
1215
|
|
@@ -1406,4 +1421,13 @@ Please refer to the [Contributing Guide](CONTRIBUTING.md).
|
|
1406
1421
|
|
1407
1422
|
## Release Process
|
1408
1423
|
|
1409
|
-
|
1424
|
+
We release `gitlab-triage` on an ad-hoc basis. There is no regularity to when
|
1425
|
+
we release, we just release when we make a change - no matter the size of the
|
1426
|
+
change.
|
1427
|
+
|
1428
|
+
To release a new version:
|
1429
|
+
|
1430
|
+
1. Create a Merge Request.
|
1431
|
+
1. Use Merge Request template [Release.md](https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage/-/blob/master/.gitlab/merge_request_templates/Release.md).
|
1432
|
+
1. Follow the instructions.
|
1433
|
+
1. After the Merge Request has been merged, a new gem version is [published automatically](https://gitlab.com/gitlab-org/quality/pipeline-common/-/blob/master/ci/gem-release.yml)
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -57,7 +57,6 @@ module Gitlab
|
|
57
57
|
|
58
58
|
assert_all!
|
59
59
|
assert_project_id!
|
60
|
-
assert_token!
|
61
60
|
require_ruby_files
|
62
61
|
end
|
63
62
|
|
@@ -101,12 +100,6 @@ module Gitlab
|
|
101
100
|
raise ArgumentError, 'A project_id is needed (pass it with the `--source-id` option)!'
|
102
101
|
end
|
103
102
|
|
104
|
-
def assert_token!
|
105
|
-
return if options.token
|
106
|
-
|
107
|
-
raise ArgumentError, 'A token is needed (pass it with the `--token` option)!'
|
108
|
-
end
|
109
|
-
|
110
103
|
def assert_all!
|
111
104
|
raise ArgumentError, '--all-projects option cannot be used in conjunction with --source and --source-id option!' if
|
112
105
|
options.all && (options.source || options.source_id)
|
@@ -335,7 +328,7 @@ module Gitlab
|
|
335
328
|
puts
|
336
329
|
end
|
337
330
|
|
338
|
-
def filter_resources(resources, conditions)
|
331
|
+
def filter_resources(resources, conditions) # rubocop:disable Metrics/CyclomaticComplexity
|
339
332
|
resources.select do |resource|
|
340
333
|
results = []
|
341
334
|
|
@@ -353,8 +346,9 @@ module Gitlab
|
|
353
346
|
results << Filters::BranchProtectedFilter.new(resource, conditions[:protected]).calculate
|
354
347
|
end
|
355
348
|
|
356
|
-
|
357
|
-
|
349
|
+
votes_condition = conditions[:votes] || conditions[:upvotes]
|
350
|
+
if votes_condition
|
351
|
+
results << Filters::VotesConditionsFilter.new(resource, votes_condition).calculate
|
358
352
|
end
|
359
353
|
|
360
354
|
if conditions[:no_additional_labels]
|
@@ -475,8 +469,13 @@ module Gitlab
|
|
475
469
|
|
476
470
|
def merge_requests_resource_query(conditions)
|
477
471
|
[].tap do |condition_builders|
|
478
|
-
|
479
|
-
|
472
|
+
[
|
473
|
+
:source_branch,
|
474
|
+
:target_branch,
|
475
|
+
:reviewer_id
|
476
|
+
].each do |key|
|
477
|
+
condition_builders << APIQueryBuilders::SingleQueryParamBuilder.new(key.to_s, conditions[key]) if conditions[key]
|
478
|
+
end
|
480
479
|
condition_builders << draft_condition_builder(conditions[:draft]) if conditions.key?(:draft)
|
481
480
|
end
|
482
481
|
end
|
@@ -54,6 +54,10 @@ module Gitlab
|
|
54
54
|
}
|
55
55
|
GRAPHQL
|
56
56
|
|
57
|
+
def vote_attribute
|
58
|
+
@vote_attribute ||= (conditions.dig(:votes, :attribute) || conditions.dig(:upvotes, :attribute)).to_s
|
59
|
+
end
|
60
|
+
|
57
61
|
def resource_fields
|
58
62
|
fields = []
|
59
63
|
|
@@ -64,8 +68,8 @@ module Gitlab
|
|
64
68
|
fields << 'labels { nodes { title } }'
|
65
69
|
fields << 'author { id name username }'
|
66
70
|
fields << 'assignees { nodes { id name username } }' if conditions.key?(:assignee_member)
|
67
|
-
fields << 'upvotes' if
|
68
|
-
fields << 'downvotes' if
|
71
|
+
fields << 'upvotes' if vote_attribute == 'upvotes'
|
72
|
+
fields << 'downvotes' if vote_attribute == 'downvotes'
|
69
73
|
fields.push('draft', 'mergedAt') if resource_type == 'merge_requests'
|
70
74
|
end
|
71
75
|
|
@@ -8,6 +8,7 @@ module Gitlab
|
|
8
8
|
module Triage
|
9
9
|
class OptionParser
|
10
10
|
class << self
|
11
|
+
# rubocop:disable Metrics/AbcSize
|
11
12
|
def parse(argv)
|
12
13
|
options = Options.new
|
13
14
|
options.host_url = 'https://gitlab.com'
|
@@ -89,9 +90,11 @@ module Gitlab
|
|
89
90
|
parser.parse!(argv)
|
90
91
|
|
91
92
|
options.source = nil if options.all
|
93
|
+
options.token ||= ''
|
92
94
|
|
93
95
|
options
|
94
96
|
end
|
97
|
+
# rubocop:enable Metrics/AbcSize
|
95
98
|
end
|
96
99
|
end
|
97
100
|
end
|
@@ -9,6 +9,18 @@ module Gitlab
|
|
9
9
|
class Issue < Base
|
10
10
|
include Shared::Issuable
|
11
11
|
|
12
|
+
DATE_FIELDS = %i[
|
13
|
+
due_date
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
DATE_FIELDS.each do |field|
|
17
|
+
define_field(field) do
|
18
|
+
value = resource[field]
|
19
|
+
|
20
|
+
Date.parse(value) if value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
def merge_requests_count
|
13
25
|
@merge_requests_count ||= resource.dig(:merge_requests_count)
|
14
26
|
end
|
@@ -30,6 +42,10 @@ module Gitlab
|
|
30
42
|
resource_url(sub_resource_type: 'links'))
|
31
43
|
.map { |issue| LinkedIssue.new(issue, parent: self) }
|
32
44
|
end
|
45
|
+
|
46
|
+
def expired?(today = Date.today)
|
47
|
+
due_date && due_date < today
|
48
|
+
end
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
@@ -10,7 +10,6 @@ module Gitlab
|
|
10
10
|
class RestAPINetwork
|
11
11
|
include Retryable
|
12
12
|
|
13
|
-
TokenNotFound = Class.new(StandardError)
|
14
13
|
MINIMUM_RATE_LIMIT = 25
|
15
14
|
|
16
15
|
attr_reader :options, :adapter
|
@@ -103,7 +102,7 @@ module Gitlab
|
|
103
102
|
private
|
104
103
|
|
105
104
|
def token
|
106
|
-
options.token
|
105
|
+
options.token
|
107
106
|
end
|
108
107
|
|
109
108
|
def rate_limit_debug(response)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-triage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|