gitlab-triage 1.0.1 → 1.1.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/README.md +47 -0
- data/lib/gitlab/triage/engine.rb +7 -0
- data/lib/gitlab/triage/option_parser.rb +4 -0
- data/lib/gitlab/triage/options.rb +1 -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: 743f14cae78b04f7df22e21ef0ce1f75a17c7d12e7b40376334f12c92f236fb9
|
4
|
+
data.tar.gz: 38d6dafa53eaacf4daecd70eb22cf726862955a2d0d37f92fcdf3e975c10ba95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0e1e9ff19465cfe990d392ea6a1332a2be2c021a9fa7bdf91af55e0c74ec1ea4d48fe7f7c7067c16fda1a34d56f69c5685d9c64a6fcf75e6a759a24e2b5f204
|
7
|
+
data.tar.gz: 452730d44ec1dd9880c57fb077411003e25988727c4eb04d277ef04229092ef04748582e6bb4f0c9008ba38cf38b99ef119e452a7e7742436a755275524747f4
|
data/README.md
CHANGED
@@ -892,6 +892,7 @@ Usage: gitlab-triage [options]
|
|
892
892
|
-p, --project-id [string] [Deprecated] A project ID or path, please use `--source-id`
|
893
893
|
-t, --token [string] A valid API token
|
894
894
|
-H, --host-url [string] A valid host url
|
895
|
+
-r, --require [string] Require a file before performing
|
895
896
|
-d, --debug Print debug information
|
896
897
|
-h, --help Print help message
|
897
898
|
--init Initialize the project with a policy file
|
@@ -945,6 +946,52 @@ host_url: https://gitlab.host.com
|
|
945
946
|
resource_rules:
|
946
947
|
```
|
947
948
|
|
949
|
+
#### Can I customize?
|
950
|
+
|
951
|
+
You can take the advantage of command line option `-r` or `--require` to
|
952
|
+
load a Ruby file before performing the actions. This allows you to do
|
953
|
+
whatever you want. For example, you can put this in a file like `my_plugin.rb`:
|
954
|
+
|
955
|
+
```ruby
|
956
|
+
module MyPlugin
|
957
|
+
def has_severity_label?
|
958
|
+
labels.grep(/^S\d+$/).any?
|
959
|
+
end
|
960
|
+
|
961
|
+
def has_priority_label?
|
962
|
+
labels.grep(/^P\d+$/).any?
|
963
|
+
end
|
964
|
+
|
965
|
+
def labels
|
966
|
+
resource[:labels]
|
967
|
+
end
|
968
|
+
end
|
969
|
+
|
970
|
+
Gitlab::Triage::Resource::Context.include MyPlugin
|
971
|
+
```
|
972
|
+
|
973
|
+
And then run it with:
|
974
|
+
|
975
|
+
```shell
|
976
|
+
gitlab-triage -r ./my_plugin.rb --token $API_TOKEN --source-id gitlab-org/triage
|
977
|
+
```
|
978
|
+
|
979
|
+
This allows you to use `has_severity_label?` in the Ruby condition:
|
980
|
+
|
981
|
+
```yml
|
982
|
+
resource_rules:
|
983
|
+
issues:
|
984
|
+
rules:
|
985
|
+
- name: Apply default severity or priority labels
|
986
|
+
conditions:
|
987
|
+
ruby: |
|
988
|
+
!has_severity_label? || !has_priority_label?
|
989
|
+
actions:
|
990
|
+
comment: |
|
991
|
+
#{'/label ~S3' unless has_severity_label?}
|
992
|
+
#{'/label ~P3' unless has_priority_label?}
|
993
|
+
```
|
994
|
+
|
948
995
|
### Contributing
|
949
996
|
|
950
997
|
Please refer to the [Contributing Guide](CONTRIBUTING.md).
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -37,6 +37,7 @@ module Gitlab
|
|
37
37
|
|
38
38
|
assert_project_id!
|
39
39
|
assert_token!
|
40
|
+
require_ruby_file
|
40
41
|
end
|
41
42
|
|
42
43
|
def perform
|
@@ -72,6 +73,12 @@ module Gitlab
|
|
72
73
|
raise ArgumentError, 'A token is needed (pass it with the `--token` option)!'
|
73
74
|
end
|
74
75
|
|
76
|
+
def require_ruby_file
|
77
|
+
return unless options.require
|
78
|
+
|
79
|
+
require options.require
|
80
|
+
end
|
81
|
+
|
75
82
|
def resource_rules
|
76
83
|
@resource_rules ||= policies.delete(:resource_rules) { {} }
|
77
84
|
end
|
@@ -47,6 +47,10 @@ module Gitlab
|
|
47
47
|
options.host_url = value
|
48
48
|
end
|
49
49
|
|
50
|
+
opts.on('-r', '--require [string]', String, 'Require a file before performing') do |value|
|
51
|
+
options.require = value
|
52
|
+
end
|
53
|
+
|
50
54
|
opts.on('-d', '--debug', 'Print debug information') do |value|
|
51
55
|
options.debug = value
|
52
56
|
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.0
|
4
|
+
version: 1.1.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-06-
|
11
|
+
date: 2019-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|