gitlab-triage 1.25.0 → 1.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42c73b8dcb5e94e895ba0daa399105f8111584523001f233a3b5344dd52e8d13
4
- data.tar.gz: 0f9c38c9aa9de8c6210cca84d6224af7647bfeec4c7fa8a73562cb4e035205e9
3
+ metadata.gz: dfb91844acb53e2543200eae19db3c5abaf9cd79106add7fa5ca7ca9585215dd
4
+ data.tar.gz: eba68ca3b8a0539f2428e63d71f86fe28ac1e292e89141fa3312192f9a21a2fd
5
5
  SHA512:
6
- metadata.gz: 264e37c9838cff91100494a72a791828e555afcac5e028a83cd0de7b86c19f9d206d1ffe0486983cd990cd51686719c660b7b04f530bd633118bc85f734a9960
7
- data.tar.gz: dd4e5b974bdf3496ee8a40eca9d69d17a3882cf40e6ac24fb8b452c500ad2fe17c8a40bd32ff1a97ad5639f7837cbdc24c993ea96d264a07a2a58985af6744b8
6
+ metadata.gz: fa86c82d57b8e4e9986039098b1c7f8f5b031dae68080bb38a84808ae6df26af48ebf0790d47558e8c9ecf6fad8ba2d7d8208ccb54a6b33cb753e0fac02139c5
7
+ data.tar.gz: cacc6bc349fa41819c5b163cd67165983021bfee35bc9f607f5a64cb283d1372db51740e4c851238e68ff15776ec6289dc280ee2ca1d11f5714c0d36f7e68013
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 --token $GITLAB_API_TOKEN --source-id $CI_PROJECT_PATH
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
- - [`upvotes` condition](#upvotes-condition)
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)
@@ -264,7 +264,7 @@ conditions:
264
264
  state: opened
265
265
  ```
266
266
 
267
- ##### Upvotes condition
267
+ ##### Votes condition
268
268
 
269
269
  Accepts a hash of fields.
270
270
 
@@ -278,7 +278,7 @@ Example:
278
278
 
279
279
  ```yml
280
280
  conditions:
281
- upvotes:
281
+ votes:
282
282
  attribute: upvotes
283
283
  condition: less_than
284
284
  threshold: 10
@@ -1195,6 +1195,7 @@ Here's a list of currently available Ruby expression API:
1195
1195
  | related_merge_requests | [MergeRequest] | The list of merge requests related to the issue |
1196
1196
  | closed_by | [MergeRequest] | The list of merge requests that close the issue |
1197
1197
  | linked_issues | [LinkedIssue] | The list of issues that are linked to the issue |
1198
+ | due_date | Date | The due date of the issue. Could be `nil` |
1198
1199
 
1199
1200
  ##### Methods for `LinkedIssue`
1200
1201
 
@@ -1406,4 +1407,13 @@ Please refer to the [Contributing Guide](CONTRIBUTING.md).
1406
1407
 
1407
1408
  ## Release Process
1408
1409
 
1409
- Please refer to the [Release Process](docs/release_process.md).
1410
+ We release `gitlab-triage` on an ad-hoc basis. There is no regularity to when
1411
+ we release, we just release when we make a change - no matter the size of the
1412
+ change.
1413
+
1414
+ To release a new version:
1415
+
1416
+ 1. Create a Merge Request.
1417
+ 1. Use Merge Request template [Release.md](https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage/-/blob/master/.gitlab/merge_request_templates/Release.md).
1418
+ 1. Follow the instructions.
1419
+ 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)
@@ -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
- if conditions[:upvotes]
357
- results << Filters::VotesConditionsFilter.new(resource, conditions[:upvotes]).calculate
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]
@@ -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 conditions.dig(:upvotes, :attribute).to_s == 'upvotes'
68
- fields << 'downvotes' if conditions.dig(:upvotes, :attribute).to_s == 'downvotes'
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 || raise(TokenNotFound)
105
+ options.token
107
106
  end
108
107
 
109
108
  def rate_limit_debug(response)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.25.0'
5
+ VERSION = '1.26.0'
6
6
  end
7
7
  end
@@ -1,4 +1,4 @@
1
- image: ruby:2.4
1
+ image: ruby:2.7
2
2
 
3
3
  stages:
4
4
  - triage
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.25.0
4
+ version: 1.26.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-10-05 00:00:00.000000000 Z
11
+ date: 2022-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport