gitlab-triage 1.19.0 → 1.20.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/lib/gitlab/triage/graphql_queries/query_builder.rb +25 -9
- data/lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb +8 -3
- data/lib/gitlab/triage/graphql_queries/query_param_builders/labels_param_builder.rb +2 -2
- data/lib/gitlab/triage/network.rb +13 -2
- data/lib/gitlab/triage/version.rb +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: 84173833ef78959cc6fdb59fa9dbe7e69ad7061265d22a1941c57a36b2f8e42b
|
4
|
+
data.tar.gz: 1293b7b39aca995152acfbed956af54c35d4897eee90f9db586bb318c20bd18c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b18f51c5386dc91946fe55531057d04908b74f42b16830458c8af11efdbac16a13791191310eddb5732764e2ffa49a89500d5fbbd8ca10a63dbae9f89acef8
|
7
|
+
data.tar.gz: ab7cefaa8a5574fb8f0e9b1c73875441975976275e28eb0f2e57194f6b26cf69323f60c3094b9d10cad88120df4abdbe112516c8c5e6a3c9f1e5e1efaad46a6f
|
@@ -82,21 +82,37 @@ module Gitlab
|
|
82
82
|
condition_queries << QueryParamBuilders::BaseParamBuilder.new('milestoneTitle', condition_params) if condition.to_s == 'milestone'
|
83
83
|
condition_queries << QueryParamBuilders::BaseParamBuilder.new('state', condition_params, with_quotes: false) if condition.to_s == 'state'
|
84
84
|
|
85
|
-
if resource_type == 'merge_requests'
|
86
|
-
|
87
|
-
condition_queries << QueryParamBuilders::BaseParamBuilder.new('sourceBranch', condition_params) if condition.to_s == 'source_branch'
|
88
|
-
condition_queries << QueryParamBuilders::BaseParamBuilder.new('targetBranch', condition_params) if condition.to_s == 'target_branch'
|
89
|
-
end
|
90
|
-
|
91
|
-
if resource_type == 'issues'
|
92
|
-
condition_queries << QueryParamBuilders::LabelsParamBuilder.new('labelName', condition_params) if condition.to_s == 'labels'
|
93
|
-
end
|
85
|
+
condition_queries << merge_requests_resource_query(condition, condition_params) if resource_type == 'merge_requests'
|
86
|
+
condition_queries << issues_resource_query(condition, condition_params) if resource_type == 'issues'
|
94
87
|
end
|
95
88
|
|
96
89
|
condition_queries
|
90
|
+
.compact
|
97
91
|
.map(&:build_param)
|
98
92
|
.join
|
99
93
|
end
|
94
|
+
|
95
|
+
def merge_requests_resource_query(condition, condition_params)
|
96
|
+
case condition.to_s
|
97
|
+
when 'forbidden_labels'
|
98
|
+
QueryParamBuilders::LabelsParamBuilder.new('labels', condition_params, negated: true)
|
99
|
+
when 'labels'
|
100
|
+
QueryParamBuilders::LabelsParamBuilder.new('labels', condition_params)
|
101
|
+
when 'source_branch'
|
102
|
+
QueryParamBuilders::BaseParamBuilder.new('sourceBranch', condition_params)
|
103
|
+
when 'target_branch'
|
104
|
+
QueryParamBuilders::BaseParamBuilder.new('targetBranch', condition_params)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def issues_resource_query(condition, condition_params)
|
109
|
+
case condition.to_s
|
110
|
+
when 'forbidden_labels'
|
111
|
+
QueryParamBuilders::LabelsParamBuilder.new('labelName', condition_params, negated: true)
|
112
|
+
when 'labels'
|
113
|
+
QueryParamBuilders::LabelsParamBuilder.new('labelName', condition_params)
|
114
|
+
end
|
115
|
+
end
|
100
116
|
end
|
101
117
|
end
|
102
118
|
end
|
@@ -5,18 +5,23 @@ module Gitlab
|
|
5
5
|
module GraphqlQueries
|
6
6
|
module QueryParamBuilders
|
7
7
|
class BaseParamBuilder
|
8
|
-
attr_reader :param_name, :param_contents, :with_quotes
|
8
|
+
attr_reader :param_name, :param_contents, :with_quotes, :negated
|
9
9
|
|
10
|
-
def initialize(param_name, param_contents, with_quotes: true)
|
10
|
+
def initialize(param_name, param_contents, with_quotes: true, negated: false)
|
11
11
|
@param_name = param_name
|
12
12
|
@param_contents = param_contents.to_s.strip
|
13
13
|
@with_quotes = with_quotes
|
14
|
+
@negated = negated
|
14
15
|
end
|
15
16
|
|
16
17
|
def build_param
|
17
18
|
contents = with_quotes ? Utils.graphql_quote(param_contents) : param_contents
|
18
19
|
|
19
|
-
|
20
|
+
if negated
|
21
|
+
", not: { #{param_name}: #{contents} }"
|
22
|
+
else
|
23
|
+
", #{param_name}: #{contents}"
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
@@ -6,10 +6,10 @@ module Gitlab
|
|
6
6
|
module GraphqlQueries
|
7
7
|
module QueryParamBuilders
|
8
8
|
class LabelsParamBuilder < BaseParamBuilder
|
9
|
-
def initialize(param_name, labels)
|
9
|
+
def initialize(param_name, labels, negated: false)
|
10
10
|
label_param_content = labels.map { |label| Utils.graphql_quote(label) }.join(', ').then { |content| "[#{content}]" }
|
11
11
|
|
12
|
-
super(param_name, label_param_content, with_quotes: false)
|
12
|
+
super(param_name, label_param_content, with_quotes: false, negated: negated)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -49,7 +49,7 @@ module Gitlab
|
|
49
49
|
when Hash
|
50
50
|
resources << results
|
51
51
|
else
|
52
|
-
|
52
|
+
raise_unexpected_response(results)
|
53
53
|
end
|
54
54
|
|
55
55
|
rate_limit_debug(response) if options.debug
|
@@ -73,7 +73,14 @@ module Gitlab
|
|
73
73
|
rate_limit_debug(response) if options.debug
|
74
74
|
rate_limit_wait(response)
|
75
75
|
|
76
|
-
response.delete(:results)
|
76
|
+
results = response.delete(:results)
|
77
|
+
|
78
|
+
case results
|
79
|
+
when Hash
|
80
|
+
results.with_indifferent_access
|
81
|
+
else
|
82
|
+
raise_unexpected_response(results)
|
83
|
+
end
|
77
84
|
rescue Net::ReadTimeout
|
78
85
|
{}
|
79
86
|
end
|
@@ -95,6 +102,10 @@ module Gitlab
|
|
95
102
|
puts Gitlab::Triage::UI.debug "Rate limit almost exceeded, sleeping for #{response[:ratelimit_reset_at] - Time.now} seconds" if options.debug
|
96
103
|
sleep(1) until Time.now >= response[:ratelimit_reset_at]
|
97
104
|
end
|
105
|
+
|
106
|
+
def raise_unexpected_response(results)
|
107
|
+
raise Errors::Network::UnexpectedResponse, "Unexpected response: #{results.inspect}"
|
108
|
+
end
|
98
109
|
end
|
99
110
|
end
|
100
111
|
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.
|
4
|
+
version: 1.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|