gitlab-triage 1.0.1 → 1.1.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: 3d45f0fbf1ce85085bd2a3af548709af191fd4dcf628760a95e5d5f73d12cecc
4
- data.tar.gz: bbef68f8e227f08dda34c5983b5ccdbb2a4cfb81b1aa29e3aeb9b82f572d0070
3
+ metadata.gz: 743f14cae78b04f7df22e21ef0ce1f75a17c7d12e7b40376334f12c92f236fb9
4
+ data.tar.gz: 38d6dafa53eaacf4daecd70eb22cf726862955a2d0d37f92fcdf3e975c10ba95
5
5
  SHA512:
6
- metadata.gz: 2100782933cf6b678b146d0f51b93222956c0d5dbe7b6cc51426e591b0a0556422f0e0dcefd26829515cc5d46d24a984017a33eaf38e2554bceaf7d200219fc7
7
- data.tar.gz: 14e182129b3d94af9f4374e6a251a7f47c4b9b85ed83a22ad029b0853cc19db5ec76c29e32f6eddd53ce27d285ad917fdd3887bf2eadf7be036adeb54ba7029e
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).
@@ -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
@@ -8,6 +8,7 @@ module Gitlab
8
8
  :token,
9
9
  :debug,
10
10
  :host_url,
11
+ :require,
11
12
  :api_version
12
13
  ) do
13
14
  def initialize(*args)
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Triage
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  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.1
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-12 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport