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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68a42526c02ea2ea87e7f0ca3d24ac0fb5acbdd145fb30fc2bbd79e533ce9b65
4
- data.tar.gz: 274ba6fb0d4040abc095207eb3349c3719e57e6e37d6087af1bedaed78e8b6b5
3
+ metadata.gz: '0609b18bd6e787fbf4e4c586b8631bc5f8c83c0a9c1a90047da3f953b558a6d6'
4
+ data.tar.gz: dec00b0fe73a998726c0c42a845aa5fa48e5b590597df4f054ed26200d4a47ca
5
5
  SHA512:
6
- metadata.gz: be15fd2ef8f9e4d12116f83906905bd43a45f0ba81978f03504aa751e97ae367f92110072abb2b2c4ae2419fd01c9599d89db3469f96c871341291dfdcddc43a
7
- data.tar.gz: e2a9669fd8373304b66d8470fe24fae0c55349c229accf9a523462ead4e63ea4f8ef3f3bc3c1d9a6765073a5d7226f8787f2feeb8a1c6c4491d6dcedbaa3af1f
6
+ metadata.gz: bb63d114b513c6a8705e47b432e5c7612fc4cbe9bf729d625286917b14341a0bfffc18ce70b06968a347b61ae8a2a629ed2c76f0e8d0c37b35a611c97b7d1045
7
+ data.tar.gz: e0752eb15014713b4ef6f1ad64494a6b3607348be75107a93a59e11659a2fa8fca4a80b4e45c8a9eca9fb7fe4ecd2dcd0923fd27bfae8d09de9ee3bf45c8e2f8
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
  - rubocop-default.yml
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 2.7
7
7
  Exclude:
8
8
  - 'vendor/**/*'
9
9
  - 'tmp/**/*'
@@ -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['iid'],
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
- label_opts = { project_id: resource[:project_id], name: label }
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,
@@ -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,9 +1,11 @@
1
- require 'httparty'
1
+ require_relative '../version'
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
5
  module NetworkAdapters
6
6
  class BaseAdapter
7
+ USER_AGENT = "GitLab Triage #{Gitlab::Triage::VERSION}".freeze
8
+
7
9
  attr_reader :options
8
10
 
9
11
  def initialize(options)
@@ -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
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.17.0'
5
+ VERSION = '1.18.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.17.0
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-07 00:00:00.000000000 Z
11
+ date: 2021-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport