gitlab-triage 1.42.2 → 1.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.git-blame-ignore-revs +43 -0
- data/.gitlab-ci.yml +51 -50
- data/.rubocop.yml +27 -0
- data/.rubocop_todo.yml +6 -442
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/Rakefile +2 -0
- data/bin/gitlab-triage +1 -0
- data/gitlab-triage.gemspec +5 -2
- data/lib/gitlab/triage/action/base.rb +5 -3
- data/lib/gitlab/triage/action.rb +2 -0
- data/lib/gitlab/triage/api_query_builders/base_query_param_builder.rb +2 -0
- data/lib/gitlab/triage/api_query_builders/date_query_param_builder.rb +3 -1
- data/lib/gitlab/triage/api_query_builders/multi_query_param_builder.rb +2 -0
- data/lib/gitlab/triage/api_query_builders/single_query_param_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/base_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/cc_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/comment_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/label_command_builder.rb +3 -1
- data/lib/gitlab/triage/command_builders/move_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/remove_label_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/status_command_builder.rb +2 -0
- data/lib/gitlab/triage/command_builders/text_content_builder.rb +2 -2
- data/lib/gitlab/triage/engine.rb +7 -2
- data/lib/gitlab/triage/errors/network.rb +2 -0
- data/lib/gitlab/triage/errors.rb +2 -0
- data/lib/gitlab/triage/expand_condition/expansion.rb +2 -0
- data/lib/gitlab/triage/expand_condition/list.rb +3 -1
- data/lib/gitlab/triage/expand_condition/sequence.rb +3 -1
- data/lib/gitlab/triage/expand_condition.rb +2 -0
- data/lib/gitlab/triage/filters/assignee_member_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/author_member_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/base_conditions_filter.rb +3 -3
- data/lib/gitlab/triage/filters/branch_date_filter.rb +2 -0
- data/lib/gitlab/triage/filters/branch_protected_filter.rb +2 -0
- data/lib/gitlab/triage/filters/discussions_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/issue_date_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/member_conditions_filter.rb +4 -4
- data/lib/gitlab/triage/filters/merge_request_date_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/name_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/ruby_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/filters/votes_conditions_filter.rb +2 -0
- data/lib/gitlab/triage/graphql_network.rb +2 -0
- data/lib/gitlab/triage/graphql_queries/query_builder.rb +3 -1
- data/lib/gitlab/triage/graphql_queries/query_param_builders/array_param_builder.rb +2 -0
- data/lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb +2 -0
- data/lib/gitlab/triage/graphql_queries/query_param_builders/date_param_builder.rb +3 -1
- data/lib/gitlab/triage/limiters/base_limiter.rb +2 -0
- data/lib/gitlab/triage/limiters/date_field_limiter.rb +2 -0
- data/lib/gitlab/triage/network.rb +2 -0
- data/lib/gitlab/triage/network_adapters/base_adapter.rb +2 -0
- data/lib/gitlab/triage/network_adapters/graphql_adapter.rb +2 -0
- data/lib/gitlab/triage/network_adapters/httparty_adapter.rb +2 -0
- data/lib/gitlab/triage/network_adapters/test_adapter.rb +3 -1
- data/lib/gitlab/triage/option_parser.rb +2 -0
- data/lib/gitlab/triage/options.rb +2 -0
- data/lib/gitlab/triage/param_builders/date_param_builder.rb +2 -0
- data/lib/gitlab/triage/resource/base.rb +3 -0
- data/lib/gitlab/triage/resource/instance_version.rb +2 -0
- data/lib/gitlab/triage/resource/milestone.rb +2 -0
- data/lib/gitlab/triage/rest_api_network.rb +2 -0
- data/lib/gitlab/triage/retryable.rb +2 -0
- data/lib/gitlab/triage/ui.rb +2 -0
- data/lib/gitlab/triage/url_builders/url_builder.rb +2 -0
- data/lib/gitlab/triage/utils.rb +2 -0
- data/lib/gitlab/triage/validators/limiter_validator.rb +3 -3
- data/lib/gitlab/triage/validators/params_validator.rb +3 -3
- data/lib/gitlab/triage/version.rb +1 -1
- data/lib/gitlab/triage.rb +2 -0
- metadata +11 -9
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'base_command_builder'
|
2
4
|
|
3
5
|
module Gitlab
|
@@ -22,7 +24,7 @@ module Gitlab
|
|
22
24
|
|
23
25
|
unless Resource::Label.new(label_opts, network: network).exist?
|
24
26
|
raise Resource::Label::LabelDoesntExistError,
|
25
|
-
|
27
|
+
"Label `#{label}` doesn't exist!"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -35,7 +35,7 @@ module Gitlab
|
|
35
35
|
items: "{{items}}",
|
36
36
|
name: "{{name}}"
|
37
37
|
}.freeze
|
38
|
-
PLACEHOLDER_REGEX = /{{([\w
|
38
|
+
PLACEHOLDER_REGEX = /{{([\w.]+)}}/
|
39
39
|
|
40
40
|
def initialize(
|
41
41
|
items, resource: nil, network: nil, redact_confidentials: true)
|
@@ -69,7 +69,7 @@ module Gitlab
|
|
69
69
|
SUPPORTED_PLACEHOLDERS.inject(item) do |comment, (placeholder, template)|
|
70
70
|
next comment unless comment.include?("{{#{placeholder}}}")
|
71
71
|
|
72
|
-
path = template[/.*#{PLACEHOLDER_REGEX}
|
72
|
+
path = template[/.*#{PLACEHOLDER_REGEX}.*/o, 1]
|
73
73
|
attributes = extract_attributes(path)
|
74
74
|
|
75
75
|
formatted_text = attributes.map do |attribute|
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'active_support/all'
|
2
4
|
require 'active_support/inflector'
|
3
5
|
|
@@ -425,7 +427,7 @@ module Gitlab
|
|
425
427
|
def decorate_resources_with_graphql_data(resources, graphql_resources)
|
426
428
|
return if graphql_resources.nil?
|
427
429
|
|
428
|
-
graphql_resources_by_id = graphql_resources.
|
430
|
+
graphql_resources_by_id = graphql_resources.index_by { |resource| resource[:id] }
|
429
431
|
resources.each { |resource| resource.merge!(graphql_resources_by_id[resource[:id]].to_h) }
|
430
432
|
end
|
431
433
|
|
@@ -467,7 +469,7 @@ module Gitlab
|
|
467
469
|
|
468
470
|
# If the :ruby condition exists then filter based off of conditions
|
469
471
|
# else we base off of the `conditions[condition_key]`.
|
470
|
-
|
472
|
+
result =
|
471
473
|
if condition_key.to_s == 'no_additional_labels'
|
472
474
|
filter.new(resource, conditions[:labels]).calculate
|
473
475
|
elsif filter.instance_method(:initialize).arity == 2
|
@@ -475,6 +477,8 @@ module Gitlab
|
|
475
477
|
else
|
476
478
|
filter.new(resource, conditions[condition_key], network).calculate
|
477
479
|
end
|
480
|
+
|
481
|
+
results << result
|
478
482
|
end
|
479
483
|
end
|
480
484
|
results.all?
|
@@ -580,6 +584,7 @@ module Gitlab
|
|
580
584
|
else
|
581
585
|
['iteration_title', iteration_value]
|
582
586
|
end
|
587
|
+
|
583
588
|
APIQueryBuilders::SingleQueryParamBuilder.new(*args)
|
584
589
|
end
|
585
590
|
|
data/lib/gitlab/triage/errors.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'expansion'
|
2
4
|
|
3
5
|
module Gitlab
|
4
6
|
module Triage
|
5
7
|
module ExpandCondition
|
6
8
|
module List
|
7
|
-
PATTERN = /\{.+?,.+?\}/m
|
9
|
+
PATTERN = /\{.+?,.+?\}/m
|
8
10
|
|
9
11
|
def self.expand(conditions)
|
10
12
|
labels = conditions[:labels]
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'expansion'
|
2
4
|
|
3
5
|
module Gitlab
|
4
6
|
module Triage
|
5
7
|
module ExpandCondition
|
6
8
|
module Sequence
|
7
|
-
PATTERN = /\{\s*(\d+)\s*\.\.\s*(\d+)\s*\}
|
9
|
+
PATTERN = /\{\s*(\d+)\s*\.\.\s*(\d+)\s*\}/
|
8
10
|
|
9
11
|
def self.expand(conditions)
|
10
12
|
labels = conditions[:labels]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/all'
|
2
4
|
require_relative '../validators/params_validator'
|
3
5
|
|
@@ -22,9 +24,7 @@ module Gitlab
|
|
22
24
|
def self.params_filter_names(params = nil)
|
23
25
|
params ||= filter_parameters
|
24
26
|
|
25
|
-
params.
|
26
|
-
param[:name]
|
27
|
-
end
|
27
|
+
params.pluck(:name)
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.all_params_filter_names
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'base_conditions_filter'
|
2
4
|
require_relative '../url_builders/url_builder'
|
3
5
|
|
@@ -43,9 +45,7 @@ module Gitlab
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def condition_value
|
46
|
-
members.
|
47
|
-
member[:username]
|
48
|
-
end
|
48
|
+
members.pluck(:username)
|
49
49
|
end
|
50
50
|
|
51
51
|
def calculate
|
@@ -55,7 +55,7 @@ module Gitlab
|
|
55
55
|
when :member_of
|
56
56
|
condition_value.include?(resource_value)
|
57
57
|
when :not_member_of
|
58
|
-
|
58
|
+
condition_value.exclude?(resource_value)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'query_param_builders/base_param_builder'
|
2
4
|
require_relative 'query_param_builders/date_param_builder'
|
3
5
|
require_relative 'query_param_builders/array_param_builder'
|
@@ -43,7 +45,7 @@ module Gitlab
|
|
43
45
|
|
44
46
|
attr_reader :source_type, :resource_type, :conditions, :graphql_only, :resource_declarations
|
45
47
|
|
46
|
-
BASE_QUERY = <<~GRAPHQL
|
48
|
+
BASE_QUERY = <<~GRAPHQL
|
47
49
|
query(%{resource_declarations}) {
|
48
50
|
%{source_type}(fullPath: $source) {
|
49
51
|
id
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../param_builders/date_param_builder'
|
2
4
|
require_relative 'base_param_builder'
|
3
5
|
|
@@ -17,7 +19,7 @@ module Gitlab
|
|
17
19
|
private
|
18
20
|
|
19
21
|
def build_param_name(condition_hash)
|
20
|
-
prefix = condition_hash[:attribute].to_s.
|
22
|
+
prefix = condition_hash[:attribute].to_s.delete_suffix('_at')
|
21
23
|
suffix =
|
22
24
|
case condition_hash[:condition].to_sym
|
23
25
|
when :older_than
|
@@ -9,6 +9,7 @@ module Gitlab
|
|
9
9
|
attr_reader :resource, :parent
|
10
10
|
|
11
11
|
CONFIDENTIAL_TEXT = '(confidential)'
|
12
|
+
SOURCE_ERROR_MSG = 'This resource is missing project_id and group_id and unable to parse source.'
|
12
13
|
|
13
14
|
def self.define_field(name, &block)
|
14
15
|
define_method(name) do
|
@@ -94,6 +95,8 @@ module Gitlab
|
|
94
95
|
'projects'
|
95
96
|
elsif resource[:group_id]
|
96
97
|
'groups'
|
98
|
+
else
|
99
|
+
raise ArgumentError, SOURCE_ERROR_MSG
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
data/lib/gitlab/triage/ui.rb
CHANGED
data/lib/gitlab/triage/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'params_validator'
|
2
4
|
|
3
5
|
module Gitlab
|
@@ -6,9 +8,7 @@ module Gitlab
|
|
6
8
|
private
|
7
9
|
|
8
10
|
def params_limiter_names
|
9
|
-
@parameter_definitions.
|
10
|
-
param[:name]
|
11
|
-
end
|
11
|
+
@parameter_definitions.pluck(:name)
|
12
12
|
end
|
13
13
|
|
14
14
|
def validate_required_parameters(value)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gitlab
|
2
4
|
module Triage
|
3
5
|
class ParamsValidator
|
@@ -33,9 +35,7 @@ module Gitlab
|
|
33
35
|
|
34
36
|
def validate_parameter_content(value)
|
35
37
|
@parameter_definitions.each do |param|
|
36
|
-
if param[:values]
|
37
|
-
raise InvalidParameter, "#{param[:name]} must be one of #{param[:values].join(',')}" unless param[:values].include?(value[param[:name]])
|
38
|
-
end
|
38
|
+
raise InvalidParameter, "#{param[:name]} must be one of #{param[:values].join(',')}" if param[:values]&.exclude?(value[param[:name]])
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/lib/gitlab/triage.rb
CHANGED
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.43.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -148,14 +148,14 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
151
|
+
version: '13.2'
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
158
|
+
version: '13.2'
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: rspec
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,7 +212,7 @@ dependencies:
|
|
212
212
|
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
|
-
description:
|
215
|
+
description:
|
216
216
|
email:
|
217
217
|
- gitlab_rubygems@gitlab.com
|
218
218
|
executables:
|
@@ -221,6 +221,7 @@ extensions: []
|
|
221
221
|
extra_rdoc_files: []
|
222
222
|
files:
|
223
223
|
- ".codeclimate.yml"
|
224
|
+
- ".git-blame-ignore-revs"
|
224
225
|
- ".gitignore"
|
225
226
|
- ".gitlab-ci.yml"
|
226
227
|
- ".gitlab/CODEOWNERS"
|
@@ -332,10 +333,11 @@ licenses:
|
|
332
333
|
- MIT
|
333
334
|
metadata:
|
334
335
|
allowed_push_host: https://rubygems.org
|
336
|
+
rubygems_mfa_required: 'false'
|
335
337
|
homepage_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage
|
336
338
|
source_code_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage
|
337
339
|
changelog_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage/-/releases
|
338
|
-
post_install_message:
|
340
|
+
post_install_message:
|
339
341
|
rdoc_options: []
|
340
342
|
require_paths:
|
341
343
|
- lib
|
@@ -350,8 +352,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
352
|
- !ruby/object:Gem::Version
|
351
353
|
version: '0'
|
352
354
|
requirements: []
|
353
|
-
rubygems_version: 3.
|
354
|
-
signing_key:
|
355
|
+
rubygems_version: 3.3.27
|
356
|
+
signing_key:
|
355
357
|
specification_version: 4
|
356
358
|
summary: GitLab triage automation project.
|
357
359
|
test_files: []
|