gitlab-triage 1.2.0 → 1.3.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/bin/gitlab-triage +9 -5
- data/lib/gitlab/triage/option_parser.rb +1 -1
- data/lib/gitlab/triage/options.rb +2 -1
- data/lib/gitlab/triage/resource/base.rb +8 -0
- data/lib/gitlab/triage/resource/shared/issuable.rb +31 -0
- data/lib/gitlab/triage/url_builders/url_builder.rb +5 -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: 3ce7441fc645df64325c4061299790c590bfbdcdb979dd53369f55231479f346
|
4
|
+
data.tar.gz: 3ca3d8cb0d811e5d3e32e2870c0aaf0d671ba5b51fd819341eae831894b131e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e7edefb97e7849ff2228ab4d842a04583b11a4d24a1f64f553e58b8a850bfc17f1f5fd00e18b436bb2ad6e0b0558cff6e1ff5f98c7fea6cee398b6ced715bc
|
7
|
+
data.tar.gz: 13bc2c8ac796534550dcef8164cd3ace9e5e99757f2f007e5c87c63b67943545ca4800a214798bd4387374b7fa3c3e49cd85682bc5db80665ce52ca1e22d61a8
|
data/bin/gitlab-triage
CHANGED
@@ -5,9 +5,13 @@ require_relative '../lib/gitlab/triage/option_parser'
|
|
5
5
|
require_relative '../lib/gitlab/triage/engine'
|
6
6
|
|
7
7
|
options = Gitlab::Triage::OptionParser.parse(ARGV)
|
8
|
-
policies_file = options.policies_file || '.triage-policies.yml'
|
9
|
-
policies = HashWithIndifferentAccess.new(YAML.load_file(policies_file))
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
policies_files = options.policies_files || ['.triage-policies.yml']
|
10
|
+
|
11
|
+
policies_files.each do |policies_file|
|
12
|
+
policies = HashWithIndifferentAccess.new(YAML.load_file(policies_file))
|
13
|
+
|
14
|
+
Gitlab::Triage::Engine
|
15
|
+
.new(policies: policies, options: options)
|
16
|
+
.perform
|
17
|
+
end
|
@@ -21,7 +21,7 @@ module Gitlab
|
|
21
21
|
end
|
22
22
|
|
23
23
|
opts.on('-f', '--policies-file [string]', String, 'A valid policies YML file') do |value|
|
24
|
-
options.
|
24
|
+
options.policies_files << value
|
25
25
|
end
|
26
26
|
|
27
27
|
opts.on('-s', '--source [type]', [:projects, :groups], 'The source type between [ projects or groups ], default value: projects') do |value|
|
@@ -2,7 +2,7 @@ module Gitlab
|
|
2
2
|
module Triage
|
3
3
|
Options = Struct.new(
|
4
4
|
:dry_run,
|
5
|
-
:
|
5
|
+
:policies_files,
|
6
6
|
:source,
|
7
7
|
:source_id,
|
8
8
|
:token,
|
@@ -19,6 +19,7 @@ module Gitlab
|
|
19
19
|
self.api_version ||= 'v4'
|
20
20
|
self.source ||= 'projects'
|
21
21
|
self.require_files ||= []
|
22
|
+
self.policies_files ||= Set.new
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -41,6 +41,14 @@ module Gitlab
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
def source_resource
|
45
|
+
@source_resource ||= network.query_api_cached(source_url).first
|
46
|
+
end
|
47
|
+
|
48
|
+
def source_url
|
49
|
+
build_url(options: { resource_type: nil })
|
50
|
+
end
|
51
|
+
|
44
52
|
def url(params = {})
|
45
53
|
build_url(params: params)
|
46
54
|
end
|
@@ -9,6 +9,9 @@ module Gitlab
|
|
9
9
|
module Resource
|
10
10
|
module Shared
|
11
11
|
module Issuable
|
12
|
+
SourceTooDeep = Class.new(RuntimeError)
|
13
|
+
MAX_PARENT_LOOKUP = 10
|
14
|
+
|
12
15
|
def milestone
|
13
16
|
@milestone ||=
|
14
17
|
resource[:milestone] &&
|
@@ -42,12 +45,40 @@ module Gitlab
|
|
42
45
|
@labels_chronologically ||= labels_with_details.sort_by(&:added_at)
|
43
46
|
end
|
44
47
|
|
48
|
+
def root_id(
|
49
|
+
namespace: source_resource[:namespace],
|
50
|
+
max_levels: MAX_PARENT_LOOKUP)
|
51
|
+
raise SourceTooDeep if max_levels <= 0
|
52
|
+
|
53
|
+
parent_id = namespace[:parent_id]
|
54
|
+
|
55
|
+
if parent_id
|
56
|
+
root_id(
|
57
|
+
namespace: request_group(parent_id)[:namespace],
|
58
|
+
max_levels: max_levels - 1)
|
59
|
+
else
|
60
|
+
namespace[:id]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
45
64
|
private
|
46
65
|
|
47
66
|
def query_label_events
|
48
67
|
network.query_api_cached(
|
49
68
|
resource_url(sub_resource_type: 'resource_label_events'))
|
50
69
|
end
|
70
|
+
|
71
|
+
def request_group(group_id)
|
72
|
+
network.query_api_cached(group_url(group_id)).first
|
73
|
+
end
|
74
|
+
|
75
|
+
def group_url(group_id)
|
76
|
+
Gitlab::Triage::UrlBuilders::UrlBuilder.new(
|
77
|
+
network_options: network.options,
|
78
|
+
source: 'groups',
|
79
|
+
source_id: group_id
|
80
|
+
).build
|
81
|
+
end
|
51
82
|
end
|
52
83
|
end
|
53
84
|
end
|
@@ -8,7 +8,7 @@ module Gitlab
|
|
8
8
|
@api_version = @network_options.api_version
|
9
9
|
@source = options.fetch(:source, 'projects')
|
10
10
|
@source_id = options.fetch(:source_id)
|
11
|
-
@resource_type = options.fetch(:resource_type)
|
11
|
+
@resource_type = options.fetch(:resource_type, nil)
|
12
12
|
@sub_resource_type = options.fetch(:sub_resource_type, nil)
|
13
13
|
@resource_id = options.fetch(:resource_id, nil)
|
14
14
|
@params = options.fetch(:params, [])
|
@@ -29,7 +29,10 @@ module Gitlab
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def base_url
|
32
|
-
"#{host_with_api_url}/#{@source}/#{CGI.escape(@source_id.to_s)}
|
32
|
+
"#{host_with_api_url}/#{@source}/#{CGI.escape(@source_id.to_s)}"
|
33
|
+
.tap do |url|
|
34
|
+
url << "/#{@resource_type}" if @resource_type
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
38
|
def params_string
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|