gitlab-triage 1.19.0 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75bd839eb28f1b1feee624b5591b623966520685ecf9577d66bd08eb68e25227
4
- data.tar.gz: 6fe5843105229f7488bc6c5e54fb58269a928bd80df3b579163636639cd64f6b
3
+ metadata.gz: 84173833ef78959cc6fdb59fa9dbe7e69ad7061265d22a1941c57a36b2f8e42b
4
+ data.tar.gz: 1293b7b39aca995152acfbed956af54c35d4897eee90f9db586bb318c20bd18c
5
5
  SHA512:
6
- metadata.gz: d0f70cecc7cd0315143783856920a36970f63d834838ad26ca3210e2077f60859a54ae1208cb1c21d7ead6c718cae36900ad47724e43cbb3c1c3ad095441d715
7
- data.tar.gz: 9044cb1de497e46b1b24f0e8ddf73da2fdd9d1dde178c4c0b1a5ff62e599c0581cb965f946ea14802a861180c9f37f72ba84fc972545b759644b528bb1865204
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
- condition_queries << QueryParamBuilders::LabelsParamBuilder.new('labels', condition_params) if condition.to_s == 'labels'
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
- ", #{param_name}: #{contents}"
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
- raise Errors::Network::UnexpectedResponse, "Unexpected response: #{results.inspect}"
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).with_indifferent_access
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.19.0'
5
+ VERSION = '1.20.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.19.0
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-06-16 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport