gitlab-triage 1.22.0 → 1.23.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: '0490c10fa9f789e91502f3cb74a56bf4a830d200a58310f3aaa0475683f0717b'
4
- data.tar.gz: 347c7aa604de9c1b042caaa21b7f8daf7e300c8aea7af175913174c51f90ed2d
3
+ metadata.gz: f64813b8d681fea2e5b23b4e53682089f4642a38037019658a3798456d219a77
4
+ data.tar.gz: 626bfa2d49c630ddab0f28c032b7665a96f07a65faa9b20da3812c538f3fcb42
5
5
  SHA512:
6
- metadata.gz: c428c46630d38c57e6c7e9db9b4d05e7d3751863163497c19f45b114a0d7b280cfe891c6bf595997ed45505881bc5f7eec4ad59934fe26a6f03f59fe3e533d63
7
- data.tar.gz: 86b73ca21f856a51c9f4d5d79e40d2470003527aeae3910f5313df11121e705d5a25698b2e129e905cec2fd17e1e3cbe193a4f84dba2eb69e3a6c0db7d6964a4
6
+ metadata.gz: 5114d8ccdeccf7da91c2326f0b25c8ab3fe2c478ac4a90051f0757b545a90fc7087b16f573eae22e6ca85f0c3e9ded9e3e8d9299f8aad806325edee83b72753b
7
+ data.tar.gz: e03e119075fb170f5cfd424b6ec07c6739efc0975c928aeeea04c60cb01e2e89e0f596b1a84cd0d446073d0d20bcb6c9cc9bad7c65f590fd1ec9c15093b9556b
data/README.md CHANGED
@@ -153,6 +153,7 @@ Used to declare a condition that must be satisfied by a resource before actions
153
153
  Available condition types:
154
154
  - [`date` condition](#date-condition)
155
155
  - [`milestone` condition](#milestone-condition)
156
+ - [`iteration` condition](#iteration-condition)
156
157
  - [`state` condition](#state-condition)
157
158
  - [`upvotes` condition](#upvotes-condition)
158
159
  - [`labels` condition](#labels-condition)
@@ -209,6 +210,25 @@ conditions:
209
210
  milestone: v1
210
211
  ```
211
212
 
213
+ ##### Iteration condition
214
+
215
+ Accepts the name of an iteration to filter upon. Also accepts the following
216
+ timebox values:
217
+
218
+ - `none`
219
+ - `any`
220
+
221
+ See the [`iteration_id` API field documentation](https://docs.gitlab.com/ee/api/issues.html) for their meaning.
222
+
223
+ Example:
224
+
225
+ ```yml
226
+ conditions:
227
+ iteration: none
228
+ ```
229
+
230
+ > **Note:** This query is not supported using GraphQL yet.
231
+
212
232
  ##### State condition
213
233
 
214
234
  Accepts a string.
@@ -1060,6 +1080,7 @@ Here's a list of currently available Ruby expression API:
1060
1080
  | ---- | ---- | ---- |
1061
1081
  | resource | Hash | The hash containing the raw data of the resource. Note that `resource[:type]` is the type of the policy (`issues`, `merge_requests`, or `epics`), not the API `type` field. |
1062
1082
  | author | String | The username of the resource author |
1083
+ | state | String | The state of the resource |
1063
1084
  | milestone | Milestone | The milestone attached to the resource |
1064
1085
  | labels | [Label] | A list of labels, having only names |
1065
1086
  | labels_with_details | [Label] | A list of labels which has more information loaded from another API request |
@@ -1069,6 +1090,14 @@ Here's a list of currently available Ruby expression API:
1069
1090
  | project_path | String | The path with namespace to the issues or merge requests project |
1070
1091
  | full_resource_reference | String | A full reference including project path to the issue or merge request |
1071
1092
 
1093
+ ##### Methods for `Issue` (issue context)
1094
+
1095
+ | Name | Return type | Description |
1096
+ | ---- | ---- | ---- |
1097
+ | merge_requests_count | Integer | The number of merge requests related to the issue |
1098
+ | related_merge_requests | [MergeRequest] | The list of merge requests related to the issue |
1099
+ | closed_by | [MergeRequest] | The list of merge requests that close the issue |
1100
+
1072
1101
  ##### Methods for `MergeRequest` (merge request context)
1073
1102
 
1074
1103
  | Method | Return type | Description |
@@ -38,6 +38,7 @@ module Gitlab
38
38
  merge_requests: %w[opened closed merged]
39
39
  }.with_indifferent_access.freeze
40
40
  MILESTONE_TIMEBOX_VALUES = %w[none any upcoming started].freeze
41
+ ITERATION_SELECTION_VALUES = %w[none any].freeze
41
42
  EpicsTriagingForProjectImpossibleError = Class.new(StandardError)
42
43
 
43
44
  def initialize(policies:, options:, network_adapter_class: DEFAULT_NETWORK_ADAPTER, graphql_network_adapter_class: DEFAULT_GRAPHQL_ADAPTER)
@@ -436,9 +437,21 @@ module Gitlab
436
437
  APIQueryBuilders::SingleQueryParamBuilder.new(*args)
437
438
  end
438
439
 
440
+ def iteration_condition_builder(iteration_value)
441
+ # Issues API should use the `iteration_id` param for timebox values, and `iteration_title` for iteration title
442
+ args =
443
+ if ITERATION_SELECTION_VALUES.include?(iteration_value.downcase)
444
+ ['iteration_id', iteration_value.titleize] # The API only accepts titleized values.
445
+ else
446
+ ['iteration_title', iteration_value]
447
+ end
448
+ APIQueryBuilders::SingleQueryParamBuilder.new(*args)
449
+ end
450
+
439
451
  def issues_resource_query(conditions)
440
452
  [].tap do |condition_builders|
441
453
  condition_builders << APIQueryBuilders::SingleQueryParamBuilder.new('weight', conditions[:weight]) if conditions[:weight]
454
+ condition_builders << iteration_condition_builder(conditions[:iteration]) if conditions[:iteration]
442
455
  end
443
456
  end
444
457
 
@@ -8,6 +8,22 @@ module Gitlab
8
8
  module Resource
9
9
  class Issue < Base
10
10
  include Shared::Issuable
11
+
12
+ def merge_requests_count
13
+ @merge_requests_count ||= resource.dig(:merge_requests_count)
14
+ end
15
+
16
+ def related_merge_requests
17
+ @related_merge_requests ||= network.query_api_cached(
18
+ resource_url(sub_resource_type: 'related_merge_requests'))
19
+ .map { |merge_request| MergeRequest.new(merge_request, parent: self) }
20
+ end
21
+
22
+ def closed_by
23
+ @closed_by ||= network.query_api_cached(
24
+ resource_url(sub_resource_type: 'closed_by'))
25
+ .map { |merge_request| MergeRequest.new(merge_request, parent: self) }
26
+ end
11
27
  end
12
28
  end
13
29
  end
@@ -47,6 +47,10 @@ module Gitlab
47
47
  @labels_chronologically ||= labels_with_details.sort_by(&:added_at)
48
48
  end
49
49
 
50
+ def state
51
+ @state ||= resource.dig(:state)
52
+ end
53
+
50
54
  def author
51
55
  @author ||= resource.dig(:author, :username)
52
56
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.22.0'
5
+ VERSION = '1.23.0'
6
6
  end
7
7
  end
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.22.0
4
+ version: 1.23.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-01-26 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport