gitlab-triage 1.17.0 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/gitlab/triage/action/comment.rb +10 -1
- data/lib/gitlab/triage/command_builders/label_command_builder.rb +5 -1
- data/lib/gitlab/triage/engine.rb +5 -0
- data/lib/gitlab/triage/graphql_network.rb +1 -1
- data/lib/gitlab/triage/network_adapters/base_adapter.rb +3 -1
- data/lib/gitlab/triage/network_adapters/graphql_adapter.rb +1 -1
- data/lib/gitlab/triage/network_adapters/httparty_adapter.rb +2 -0
- 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: '0609b18bd6e787fbf4e4c586b8631bc5f8c83c0a9c1a90047da3f953b558a6d6'
|
4
|
+
data.tar.gz: dec00b0fe73a998726c0c42a845aa5fa48e5b590597df4f054ed26200d4a47ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb63d114b513c6a8705e47b432e5c7612fc4cbe9bf729d625286917b14341a0bfffc18ce70b06968a347b61ae8a2a629ed2c76f0e8d0c37b35a611c97b7d1045
|
7
|
+
data.tar.gz: e0752eb15014713b4ef6f1ad64494a6b3607348be75107a93a59e11659a2fa8fca4a80b4e45c8a9eca9fb7fe4ecd2dcd0923fd27bfae8d09de9ee3bf45c8e2f8
|
data/.rubocop.yml
CHANGED
@@ -62,7 +62,7 @@ module Gitlab
|
|
62
62
|
source: policy.source,
|
63
63
|
source_id: resource[policy.source_id_sym],
|
64
64
|
resource_type: policy.type,
|
65
|
-
resource_id: resource
|
65
|
+
resource_id: resource_id(resource),
|
66
66
|
sub_resource_type: sub_resource_type
|
67
67
|
}
|
68
68
|
|
@@ -84,6 +84,15 @@ module Gitlab
|
|
84
84
|
raise ArgumentError, "Unknown comment type: #{type}"
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
def resource_id(resource)
|
89
|
+
case policy.type
|
90
|
+
when 'epics'
|
91
|
+
resource['id']
|
92
|
+
else
|
93
|
+
resource['iid']
|
94
|
+
end
|
95
|
+
end
|
87
96
|
end
|
88
97
|
end
|
89
98
|
end
|
@@ -14,7 +14,11 @@ module Gitlab
|
|
14
14
|
|
15
15
|
def ensure_labels_exist!
|
16
16
|
items.each do |label|
|
17
|
-
|
17
|
+
source_id_key = resource.key?(:group_id) ? :group_id : :project_id
|
18
|
+
label_opts = {
|
19
|
+
source_id_key => resource[source_id_key],
|
20
|
+
name: label
|
21
|
+
}
|
18
22
|
|
19
23
|
unless Resource::Label.new(label_opts, network: network).exist?
|
20
24
|
raise Resource::Label::LabelDoesntExistError,
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -37,6 +37,7 @@ module Gitlab
|
|
37
37
|
issues: %w[opened closed],
|
38
38
|
merge_requests: %w[opened closed merged]
|
39
39
|
}.with_indifferent_access.freeze
|
40
|
+
EpicsTriagingForProjectImpossibleError = Class.new(StandardError)
|
40
41
|
|
41
42
|
def initialize(policies:, options:, network_adapter_class: DEFAULT_NETWORK_ADAPTER, graphql_network_adapter_class: DEFAULT_GRAPHQL_ADAPTER)
|
42
43
|
options.host_url = policies.delete(:host_url) { options.host_url }
|
@@ -62,6 +63,10 @@ module Gitlab
|
|
62
63
|
puts
|
63
64
|
|
64
65
|
resource_rules.each do |resource_type, resource|
|
66
|
+
if resource_type == 'epics' && options.source != :groups
|
67
|
+
raise(EpicsTriagingForProjectImpossibleError, "Epics can only be triaged at the group level. Please set the `--source groups` option.")
|
68
|
+
end
|
69
|
+
|
65
70
|
puts Gitlab::Triage::UI.header("Processing rules for #{resource_type}", char: '-')
|
66
71
|
puts
|
67
72
|
|
@@ -51,7 +51,7 @@ module Gitlab
|
|
51
51
|
|
52
52
|
def normalize(resource)
|
53
53
|
resource
|
54
|
-
.slice(:iid, :state, :author, :merged_at, :user_notes_count, :user_discussions_count, :upvotes, :downvotes, :project_id, :web_url)
|
54
|
+
.slice(:iid, :title, :state, :author, :merged_at, :user_notes_count, :user_discussions_count, :upvotes, :downvotes, :project_id, :web_url)
|
55
55
|
.merge(
|
56
56
|
id: extract_id_from_global_id(resource[:id]),
|
57
57
|
labels: [*resource.dig(:labels, :nodes)].pluck(:title),
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'httparty'
|
2
1
|
require 'graphql/client'
|
3
2
|
require 'graphql/client/http'
|
4
3
|
|
@@ -64,6 +63,7 @@ module Gitlab
|
|
64
63
|
uri,
|
65
64
|
body: body.to_json,
|
66
65
|
headers: {
|
66
|
+
'User-Agent' => USER_AGENT,
|
67
67
|
'Content-type' => 'application/json',
|
68
68
|
'PRIVATE-TOKEN' => context[:token]
|
69
69
|
}
|
@@ -12,6 +12,7 @@ module Gitlab
|
|
12
12
|
response = HTTParty.get(
|
13
13
|
url,
|
14
14
|
headers: {
|
15
|
+
'User-Agent' => USER_AGENT,
|
15
16
|
'Content-type' => 'application/json',
|
16
17
|
'PRIVATE-TOKEN' => token
|
17
18
|
}
|
@@ -35,6 +36,7 @@ module Gitlab
|
|
35
36
|
url,
|
36
37
|
body: body.to_json,
|
37
38
|
headers: {
|
39
|
+
'User-Agent' => "GitLab Triage #{Gitlab::Triage::VERSION}",
|
38
40
|
'Content-type' => 'application/json',
|
39
41
|
'PRIVATE-TOKEN' => token
|
40
42
|
}
|
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.18.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-05-
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|