gitlab-triage 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -2
- data/README.md +33 -10
- data/gitlab-triage.gemspec +1 -1
- data/lib/gitlab/triage/action/comment.rb +1 -1
- data/lib/gitlab/triage/action/summarize.rb +1 -1
- data/lib/gitlab/triage/engine.rb +6 -4
- data/lib/gitlab/triage/option_parser.rb +13 -2
- data/lib/gitlab/triage/options.rb +3 -1
- data/lib/gitlab/triage/ui.rb +4 -0
- data/lib/gitlab/triage/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 151d7ca8651d7f913171ef8fe50a1128d2101df9286d88cffe57cbc20d50f254
|
4
|
+
data.tar.gz: 81a9fab0da6480444ad0498a361c364efac00c63c3db56b3d26b433a6f83f388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa57bcfddb6a36c963cd1bd80903deef7c03d82bc77e259d5d71d9edc01dcf9b7786d0b88b79110273c7167fc6b74339da904470c79d648b8ed50ebd1b2ceb88
|
7
|
+
data.tar.gz: 92929ba6651a46241581dac4d3a3ec902e959ecea660b51cb7a861dba32f9418a760d9bcaaedf645439e39e6bdd5462880d9b1c635a90d3a9cf6499d372d43e8
|
data/.gitlab-ci.yml
CHANGED
@@ -82,7 +82,7 @@ dry-run:gitlab-triage:
|
|
82
82
|
- bundle exec rake install:local
|
83
83
|
- gitlab-triage --help
|
84
84
|
- gitlab-triage --init
|
85
|
-
- gitlab-triage --dry-run --debug --token $API_TOKEN --
|
85
|
+
- gitlab-triage --dry-run --debug --token $API_TOKEN --source-id $CI_PROJECT_PATH
|
86
86
|
|
87
87
|
dry-run:gitlab-ce:
|
88
88
|
<<: *pull-cache
|
@@ -90,5 +90,5 @@ dry-run:gitlab-ce:
|
|
90
90
|
script:
|
91
91
|
- bundle exec rake install:local
|
92
92
|
- gitlab-triage --help
|
93
|
-
- gitlab-triage --dry-run --debug --token $API_TOKEN --
|
93
|
+
- gitlab-triage --dry-run --debug --token $API_TOKEN --source-id gitlab-org/gitlab-ce
|
94
94
|
when: manual
|
data/README.md
CHANGED
@@ -9,8 +9,11 @@ This project contains the library and pipeline definition to enable automated tr
|
|
9
9
|
### Abstract
|
10
10
|
|
11
11
|
The `gitlab-triage` gem aims to enable project managers and maintainers to
|
12
|
-
automatically triage Issues and Merge Requests in GitLab projects
|
13
|
-
defined policies.
|
12
|
+
automatically triage Issues and Merge Requests in GitLab projects or groups
|
13
|
+
based on defined policies.
|
14
|
+
|
15
|
+
See [Running locally](#running-locally) for how to specify a project or a
|
16
|
+
group.
|
14
17
|
|
15
18
|
### What is a triage policy?
|
16
19
|
|
@@ -258,6 +261,10 @@ resource_rules:
|
|
258
261
|
- Quality
|
259
262
|
```
|
260
263
|
|
264
|
+
> Note:
|
265
|
+
> If you want to define a full label expansion, you'll need to [force string](https://yaml.org/YAML_for_ruby.html#forcing_strings) or [quote string](https://yaml.org/YAML_for_ruby.html#single-quoted_strings) because otherwise it won't be considered a string due to the YAML parser.
|
266
|
+
> For example, we can quote the expression like `'{ apple, orange }'`, which will create 2 rules, for the two specified labels.
|
267
|
+
|
261
268
|
###### Sequence
|
262
269
|
|
263
270
|
The name of a label can contain one or more sequence conditions, written
|
@@ -832,14 +839,24 @@ Here's a list of currently available Ruby expression API:
|
|
832
839
|
| version_short | String | The short string of version. e.g. `11.3` |
|
833
840
|
| revision | String | The revision of GitLab. e.g. `231b0c7` |
|
834
841
|
|
842
|
+
### Installation
|
843
|
+
|
844
|
+
gem install gitlab-triage
|
845
|
+
|
835
846
|
### Usage
|
836
847
|
|
848
|
+
gitlab-triage --help
|
849
|
+
|
850
|
+
Will show:
|
851
|
+
|
837
852
|
```
|
838
853
|
Usage: gitlab-triage [options]
|
839
854
|
|
840
855
|
-n, --dry-run Don't actually update anything, just print
|
841
856
|
-f, --policies-file [string] A valid policies YML file
|
842
|
-
-
|
857
|
+
-s, --source [type] The source type between [ projects or groups ], default value: projects
|
858
|
+
-i, --source-id [string] Source ID or path
|
859
|
+
-p, --project-id [string] [Deprecated] A project ID or path, please use `--source-id`
|
843
860
|
-t, --token [string] A valid API token
|
844
861
|
-H, --host-url [string] A valid host url
|
845
862
|
-d, --debug Print debug information
|
@@ -848,15 +865,21 @@ Usage: gitlab-triage [options]
|
|
848
865
|
--init-ci Initialize the project with a .gitlab-ci.yml file
|
849
866
|
```
|
850
867
|
|
851
|
-
####
|
868
|
+
#### Running locally
|
869
|
+
|
870
|
+
Triaging against a specific project:
|
871
|
+
|
872
|
+
```
|
873
|
+
gitlab-triage --dry-run --token $API_TOKEN --source-id gitlab-org/triage
|
874
|
+
```
|
875
|
+
|
876
|
+
Triaging against a whole group:
|
852
877
|
|
853
878
|
```
|
854
|
-
|
855
|
-
gitlab-triage --help
|
856
|
-
gitlab-triage --dry-run --token $API_TOKEN --project-id gitlab-org/triage
|
879
|
+
gitlab-triage --dry-run --token $API_TOKEN --source-id gitlab-org --source groups
|
857
880
|
```
|
858
881
|
|
859
|
-
#### GitLab CI pipeline
|
882
|
+
#### Running on GitLab CI pipeline
|
860
883
|
|
861
884
|
You can enforce policies using a scheduled pipeline:
|
862
885
|
|
@@ -865,7 +888,7 @@ run:triage:triage:
|
|
865
888
|
stage: triage
|
866
889
|
script:
|
867
890
|
- gem install gitlab-triage
|
868
|
-
- gitlab-triage --token $API_TOKEN --
|
891
|
+
- gitlab-triage --token $API_TOKEN --source-id $CI_PROJECT_PATH
|
869
892
|
only:
|
870
893
|
- schedules
|
871
894
|
```
|
@@ -879,7 +902,7 @@ Yes, you can override the host url using the following options:
|
|
879
902
|
##### CLI
|
880
903
|
|
881
904
|
```
|
882
|
-
gitlab-triage --dry-run --token $API_TOKEN --
|
905
|
+
gitlab-triage --dry-run --token $API_TOKEN --source-id gitlab-org/triage --host-url https://gitlab.host.com
|
883
906
|
```
|
884
907
|
|
885
908
|
##### Policy file
|
data/gitlab-triage.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'activesupport', '~> 5.1'
|
23
23
|
spec.add_dependency 'httparty', '~> 0.15'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'gitlab-styles', '~> 2.1'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
@@ -58,7 +58,7 @@ module Gitlab
|
|
58
58
|
# POST /projects/:id/issues/:issue_iid/notes
|
59
59
|
post_url = UrlBuilders::UrlBuilder.new(
|
60
60
|
network_options: network.options,
|
61
|
-
source_id:
|
61
|
+
source_id: resource[:project_id],
|
62
62
|
resource_type: policy.type,
|
63
63
|
resource_id: resource['iid'],
|
64
64
|
sub_resource_type: 'notes'
|
@@ -37,7 +37,7 @@ module Gitlab
|
|
37
37
|
# https://docs.gitlab.com/ee/api/issues.html#new-issue
|
38
38
|
post_url = UrlBuilders::UrlBuilder.new(
|
39
39
|
network_options: network.options,
|
40
|
-
source_id: network.options.
|
40
|
+
source_id: network.options.source_id,
|
41
41
|
resource_type: 'issues'
|
42
42
|
).build
|
43
43
|
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/all'
|
2
|
+
require 'active_support/inflector'
|
2
3
|
|
3
4
|
require_relative 'expand_condition'
|
4
5
|
require_relative 'filters/date_conditions_filter'
|
@@ -41,7 +42,7 @@ module Gitlab
|
|
41
42
|
def perform
|
42
43
|
puts "Performing a dry run.\n\n" if options.dry_run
|
43
44
|
|
44
|
-
puts Gitlab::Triage::UI.header("Triaging the `#{options.
|
45
|
+
puts Gitlab::Triage::UI.header("Triaging the `#{options.source_id}` #{options.source.to_s.singularize}", char: '=')
|
45
46
|
puts
|
46
47
|
|
47
48
|
resource_rules.each do |resource_type, resource|
|
@@ -60,9 +61,9 @@ module Gitlab
|
|
60
61
|
private
|
61
62
|
|
62
63
|
def assert_project_id!
|
63
|
-
return if options.
|
64
|
+
return if options.source_id
|
64
65
|
|
65
|
-
raise ArgumentError, 'A project_id is needed (pass it with the `--
|
66
|
+
raise ArgumentError, 'A project_id is needed (pass it with the `--source-id` option)!'
|
66
67
|
end
|
67
68
|
|
68
69
|
def assert_token!
|
@@ -198,7 +199,8 @@ module Gitlab
|
|
198
199
|
|
199
200
|
UrlBuilders::UrlBuilder.new(
|
200
201
|
network_options: options,
|
201
|
-
|
202
|
+
source: options.source,
|
203
|
+
source_id: options.source_id,
|
202
204
|
resource_type: resource_type,
|
203
205
|
params: params
|
204
206
|
).build
|
@@ -24,8 +24,19 @@ module Gitlab
|
|
24
24
|
options.policies_file = value
|
25
25
|
end
|
26
26
|
|
27
|
-
opts.on('-
|
28
|
-
options.
|
27
|
+
opts.on('-s', '--source [type]', [:projects, :groups], 'The source type between [ projects or groups ], default value: projects') do |value|
|
28
|
+
options.source = value
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on('-i', '--source-id [string]', String, 'Source ID or path') do |value|
|
32
|
+
options.source_id = value
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on('-p', '--project-id [string]', String, '[Deprecated] A project ID or path, please use `--source-id`') do |value|
|
36
|
+
puts Gitlab::Triage::UI.warn("The option `--project-id` has been deprecated, please use `--source-id` instead")
|
37
|
+
puts
|
38
|
+
options.source = 'projects'
|
39
|
+
options.source_id = value
|
29
40
|
end
|
30
41
|
|
31
42
|
opts.on('-t', '--token [string]', String, 'A valid API token') do |value|
|
@@ -3,7 +3,8 @@ module Gitlab
|
|
3
3
|
Options = Struct.new(
|
4
4
|
:dry_run,
|
5
5
|
:policies_file,
|
6
|
-
:
|
6
|
+
:source,
|
7
|
+
:source_id,
|
7
8
|
:token,
|
8
9
|
:debug,
|
9
10
|
:host_url,
|
@@ -15,6 +16,7 @@ module Gitlab
|
|
15
16
|
# Defaults
|
16
17
|
self.host_url ||= 'https://gitlab.com'
|
17
18
|
self.api_version ||= 'v4'
|
19
|
+
self.source ||= 'projects'
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/gitlab/triage/ui.rb
CHANGED
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: 0.
|
4
|
+
version: 0.16.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-
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: gitlab-styles
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|