gitlab-triage 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.triage-policies.yml +14 -14
- data/README.md +48 -3
- data/bin/gitlab-triage +7 -1
- data/lib/gitlab/triage/command_builders/base_command_builder.rb +5 -1
- data/lib/gitlab/triage/command_builders/comment_body_builder.rb +66 -0
- data/lib/gitlab/triage/command_builders/comment_command_builder.rb +0 -4
- data/lib/gitlab/triage/engine.rb +11 -10
- data/lib/gitlab/triage/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82746964d894d23cf152a4a5fb996e23216355bba6aa639cb6ea339dcf6fd13
|
4
|
+
data.tar.gz: cc931bd1c1e8f4097e3463b4351f426e39b69cbdbb9dc2e4ac7dafd426659de7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25effb45c3c03772ade06f3c8fee5b69598917a541aaece754fe053fc77f4bf92d8e74739d9cc3fe605ec275df73cc1c2110615b43d8ee0c57cf2fd3db2e8b3e
|
7
|
+
data.tar.gz: 7c40513edecbed3ab28f9fd116fc554bd6a4fc9dfc828d461a2bccfa4d166aa0960385a1865c487c88172f348a62c19e9a0a197b626aba5e8c8ef1ba5bf6109c
|
data/.triage-policies.yml
CHANGED
@@ -18,7 +18,7 @@ resource_rules:
|
|
18
18
|
mention:
|
19
19
|
- markglenfletcher
|
20
20
|
comment: |
|
21
|
-
Hi,
|
21
|
+
Hi {{author}},
|
22
22
|
|
23
23
|
First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
|
24
24
|
|
@@ -50,7 +50,7 @@ resource_rules:
|
|
50
50
|
mention:
|
51
51
|
- markglenfletcher
|
52
52
|
comment: |
|
53
|
-
Hi,
|
53
|
+
Hi {{author}},
|
54
54
|
|
55
55
|
First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
|
56
56
|
|
@@ -83,7 +83,7 @@ resource_rules:
|
|
83
83
|
- markglenfletcher
|
84
84
|
status: close
|
85
85
|
comment: |
|
86
|
-
Closing this issue down in accordance with our [Issue Triage Policies](https://gitlab.com/gitlab-org/triage). Please reopen the issue if you feel that the issue is still relevant. Thanks!
|
86
|
+
{{author}} Closing this issue down in accordance with our [Issue Triage Policies](https://gitlab.com/gitlab-org/triage). Please reopen the issue if you feel that the issue is still relevant. Thanks!
|
87
87
|
- name: Mark potentially interesting feature proposals
|
88
88
|
conditions:
|
89
89
|
labels:
|
@@ -122,15 +122,15 @@ resource_rules:
|
|
122
122
|
mention:
|
123
123
|
- markglenfletcher
|
124
124
|
comment: |
|
125
|
-
Hi,
|
125
|
+
Hi {{author}},
|
126
126
|
|
127
127
|
First of all, thank you for raising an issue to help improve the GitLab product. This issue was labelled as a ~"feature proposal" in the past. In order to maintain order in the issue tracker, we are starting to close off old, unpopular feature proposals that have not gained many votes since opening.
|
128
128
|
|
129
129
|
This issue will be closed, as it meets the following criteria:
|
130
|
-
* No activity in the past 12 months
|
131
|
-
*
|
130
|
+
* No activity in the past 12 months (last update was {{updated_at}})
|
131
|
+
* Current labels ({{labels}}) include ~"feature proposal"
|
132
132
|
* Unscheduled (not associated with a milestone)
|
133
|
-
* Less than 10 upvotes
|
133
|
+
* Less than 10 upvotes (currently {{upvotes}} upvotes)
|
134
134
|
|
135
135
|
Thanks for your help and please raise any new feature proposals as a new issue.
|
136
136
|
- name: Mark very popular, unscheduled feature proposals
|
@@ -167,14 +167,14 @@ resource_rules:
|
|
167
167
|
mention:
|
168
168
|
- markglenfletcher
|
169
169
|
comment: |
|
170
|
-
Hi,
|
170
|
+
Hi {{author}},
|
171
171
|
|
172
172
|
First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
|
173
173
|
|
174
174
|
This issue will be marked for closure, as it meets the following criteria:
|
175
175
|
* Issue is open
|
176
|
-
* No activity in the past 6 months
|
177
|
-
*
|
176
|
+
* No activity in the past 6 months (last update was {{updated_at}})
|
177
|
+
* Current labels ({{labels}}) include ~bug
|
178
178
|
* Unscheduled (no milestone)
|
179
179
|
|
180
180
|
We'd like to ask you to help us out and determine whether this issue should be reopened.
|
@@ -201,14 +201,14 @@ resource_rules:
|
|
201
201
|
mention:
|
202
202
|
- rymai
|
203
203
|
comment: |
|
204
|
-
Hi,
|
204
|
+
Hi {{author}},
|
205
205
|
|
206
|
-
First of all, thank you for creating a Merge Request to help improve the GitLab product. We are running through old Merge Requests and asking authors to update their Merge Requests
|
206
|
+
First of all, thank you for creating a Merge Request to help improve the GitLab product. We are running through old Merge Requests and asking authors to update their Merge Requests
|
207
207
|
|
208
208
|
This Merge Request was chosen, as it meets the following criteria:
|
209
209
|
* Open
|
210
|
-
*
|
211
|
-
*
|
210
|
+
* No activity in the past 6 months (last update was {{updated_at}})
|
211
|
+
* Current labels ({{labels}}) include ~"Community Contribution"
|
212
212
|
|
213
213
|
We'd like to ask you to help us out and let us know whether:
|
214
214
|
* You would like to continue the work here
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ resource_rules:
|
|
52
52
|
mention:
|
53
53
|
- markglenfletcher
|
54
54
|
comment: |
|
55
|
-
This issue is unlabelled after 5 days. It needs attention.
|
55
|
+
{{author}} This issue is unlabelled after 5 days. It needs attention.
|
56
56
|
merge_requests:
|
57
57
|
rules:
|
58
58
|
[]
|
@@ -329,9 +329,30 @@ actions:
|
|
329
329
|
|
330
330
|
Adds a comment to the resource.
|
331
331
|
|
332
|
-
Accepts a string.
|
332
|
+
Accepts a string, and placeholders. Placeholders should be wrapped in double
|
333
|
+
curly braces, e.g. `{{author}}`.
|
333
334
|
|
334
|
-
|
335
|
+
The following placeholders are supported:
|
336
|
+
|
337
|
+
- `created_at`: the resource's creation date
|
338
|
+
- `updated_at`: the resource's last update date
|
339
|
+
- `closed_at`: the resource's closed date (if applicable)
|
340
|
+
- `merged_at`: the resource's merged date (if applicable)
|
341
|
+
- `state`: the resources's current state: `opened`, `closed`, `merged`
|
342
|
+
- `author`: the username of the resource's author as `@user1`
|
343
|
+
- `assignee`: the username of the resource's assignee as `@user1`
|
344
|
+
- `assignees`: the usernames of the resource's assignees as `@user1, @user2`
|
345
|
+
- `closed_by`: the user that closed the resource as `@user1` (if applicable)
|
346
|
+
- `merged_by`: the user that merged the resource as `@user1` (if applicable)
|
347
|
+
- `milestone`: the resource's current milestone
|
348
|
+
- `labels`: the resource's labels as `~label1, ~label2`
|
349
|
+
- `upvotes`: the resources's upvotes count
|
350
|
+
- `downvotes`: the resources's downvotes count
|
351
|
+
|
352
|
+
If the resource doesn't respond to the placeholder, or if the field is `nil`,
|
353
|
+
the placeholder is not replaced.
|
354
|
+
|
355
|
+
Example without placeholders:
|
335
356
|
|
336
357
|
```yml
|
337
358
|
actions:
|
@@ -339,6 +360,14 @@ actions:
|
|
339
360
|
Closing this issue automatically
|
340
361
|
```
|
341
362
|
|
363
|
+
Example with placeholders:
|
364
|
+
|
365
|
+
```yml
|
366
|
+
actions:
|
367
|
+
comment: |
|
368
|
+
@{{author}} Are you still interested in finishing this merge request?
|
369
|
+
```
|
370
|
+
|
342
371
|
### Usage
|
343
372
|
|
344
373
|
```
|
@@ -348,6 +377,7 @@ Usage: gitlab-triage [options]
|
|
348
377
|
-f, --policies-file [string] A valid policies YML file
|
349
378
|
-p, --project-id [string] A project ID or path
|
350
379
|
-t, --token [string] A valid API token
|
380
|
+
-H, --host-url [string] A valid host url
|
351
381
|
-d, --debug Print debug information
|
352
382
|
-h, --help Print help message
|
353
383
|
--init Initialize the project with a policy file
|
@@ -378,6 +408,21 @@ run:triage:triage:
|
|
378
408
|
|
379
409
|
> Note: You can use the [`--init-ci`](#usage) option to add an example [`.gitlab-ci.yml` file](support/.gitlab-ci.example.yml) to your project
|
380
410
|
|
411
|
+
#### Can I use gitlab-triage for my self-hosted GitLab instance?
|
412
|
+
|
413
|
+
Yes, you can override the host url using the following options:
|
414
|
+
|
415
|
+
##### CLI
|
416
|
+
```
|
417
|
+
gitlab-triage --dry-run --token $API_TOKEN --project-id gitlab-org/triage --host-url https://gitlab.host.com
|
418
|
+
```
|
419
|
+
|
420
|
+
##### Policy file
|
421
|
+
```yml
|
422
|
+
host_url: https://gitlab.host.com
|
423
|
+
resource_rules:
|
424
|
+
```
|
425
|
+
|
381
426
|
### Contributing
|
382
427
|
|
383
428
|
Please refer to the [Contributing Guide](CONTRIBUTING.md)
|
data/bin/gitlab-triage
CHANGED
@@ -9,13 +9,15 @@ Options = Struct.new(
|
|
9
9
|
:policies_file,
|
10
10
|
:project_id,
|
11
11
|
:token,
|
12
|
-
:debug
|
12
|
+
:debug,
|
13
|
+
:host_url
|
13
14
|
)
|
14
15
|
|
15
16
|
class TriageOptionParser
|
16
17
|
class << self
|
17
18
|
def parse(argv)
|
18
19
|
options = Options.new
|
20
|
+
options.host_url = 'https://gitlab.com'
|
19
21
|
|
20
22
|
parser = OptionParser.new do |opts|
|
21
23
|
opts.banner = "Usage: #{__FILE__} [options]\n\n"
|
@@ -36,6 +38,10 @@ class TriageOptionParser
|
|
36
38
|
options.token = value
|
37
39
|
end
|
38
40
|
|
41
|
+
opts.on('-H', '--host-url [string]', String, 'A valid host url') do |value|
|
42
|
+
options.host_url = value
|
43
|
+
end
|
44
|
+
|
39
45
|
opts.on('-d', '--debug', 'Print debug information') do |value|
|
40
46
|
options.debug = value
|
41
47
|
end
|
@@ -3,7 +3,7 @@ module Gitlab
|
|
3
3
|
module CommandBuilders
|
4
4
|
class BaseCommandBuilder
|
5
5
|
def initialize(items)
|
6
|
-
@items =
|
6
|
+
@items = Array(items)
|
7
7
|
@items.delete('')
|
8
8
|
end
|
9
9
|
|
@@ -21,6 +21,10 @@ module Gitlab
|
|
21
21
|
' '
|
22
22
|
end
|
23
23
|
|
24
|
+
def slash_command_string
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
24
28
|
def content_string
|
25
29
|
@items.map do |item|
|
26
30
|
format_item(item)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'base_command_builder'
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Triage
|
5
|
+
module CommandBuilders
|
6
|
+
class CommentBodyBuilder < BaseCommandBuilder
|
7
|
+
SUPPORTED_PLACEHOLDERS = {
|
8
|
+
created_at: "{{created_at}}".freeze,
|
9
|
+
updated_at: "{{updated_at}}".freeze,
|
10
|
+
closed_at: "{{closed_at}}".freeze,
|
11
|
+
merged_at: "{{merged_at}}".freeze,
|
12
|
+
state: "{{state}}".freeze,
|
13
|
+
author: "@{{author.username}}".freeze,
|
14
|
+
assignee: "@{{assignee.username}}".freeze,
|
15
|
+
assignees: "@{{assignees.username}}".freeze,
|
16
|
+
closed_by: "@{{closed_by.username}}".freeze,
|
17
|
+
merged_by: "@{{merged_by.username}}".freeze,
|
18
|
+
milestone: %(%"{{milestone.title}}").freeze,
|
19
|
+
labels: %(~"{{labels}}").freeze,
|
20
|
+
upvotes: "{{upvotes}}".freeze,
|
21
|
+
downvotes: "{{downvotes}}".freeze
|
22
|
+
}.freeze
|
23
|
+
PLACEHOLDER_REGEX = /{{([\w\.]+)}}/
|
24
|
+
|
25
|
+
attr_reader :resource
|
26
|
+
|
27
|
+
def initialize(items, resource: nil)
|
28
|
+
super(items)
|
29
|
+
@resource = resource
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def separator
|
35
|
+
"\n\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_item(item)
|
39
|
+
return item unless resource
|
40
|
+
|
41
|
+
SUPPORTED_PLACEHOLDERS.each do |placeholder, formatted_text|
|
42
|
+
next unless item.include?("{{#{placeholder}}}")
|
43
|
+
|
44
|
+
methods = formatted_text.match(/.*#{PLACEHOLDER_REGEX}.*/)[1].split('.')
|
45
|
+
fields = resource_fields(resource, methods)
|
46
|
+
|
47
|
+
final_fields = fields.map { |field| formatted_text.sub(PLACEHOLDER_REGEX, field.to_s) }
|
48
|
+
item.gsub!("{{#{placeholder}}}", final_fields.join(', ')) if final_fields.any?
|
49
|
+
end
|
50
|
+
|
51
|
+
item
|
52
|
+
end
|
53
|
+
|
54
|
+
def resource_fields(resource, methods)
|
55
|
+
method = methods.shift
|
56
|
+
|
57
|
+
return Array(resource) unless method && resource
|
58
|
+
return [] unless resource.key?(method)
|
59
|
+
|
60
|
+
sub_resources = resource[method]
|
61
|
+
Array.wrap(sub_resources).flat_map { |res| resource_fields(res, methods.dup) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/gitlab/triage/engine.rb
CHANGED
@@ -6,6 +6,7 @@ require_relative 'limiters/forbidden_labels_conditions_limiter'
|
|
6
6
|
require_relative 'limiters/no_additional_labels_conditions_limiter'
|
7
7
|
require_relative 'limiters/author_member_conditions_limiter'
|
8
8
|
require_relative 'limiters/assignee_member_conditions_limiter'
|
9
|
+
require_relative 'command_builders/comment_body_builder'
|
9
10
|
require_relative 'command_builders/comment_command_builder'
|
10
11
|
require_relative 'command_builders/label_command_builder'
|
11
12
|
require_relative 'command_builders/remove_label_command_builder'
|
@@ -24,7 +25,7 @@ module Gitlab
|
|
24
25
|
attr_reader :host_url, :api_version, :per_page, :policies, :options
|
25
26
|
|
26
27
|
def initialize(policies:, options:, network_adapter_class: Gitlab::Triage::NetworkAdapters::HttpartyAdapter)
|
27
|
-
@host_url = policies.delete(:host_url) {
|
28
|
+
@host_url = policies.delete(:host_url) { options.host_url }
|
28
29
|
@api_version = policies.delete(:api_version) { 'v4' }
|
29
30
|
@per_page = policies.delete(:per_page) { 100 }
|
30
31
|
@policies = policies
|
@@ -110,23 +111,23 @@ module Gitlab
|
|
110
111
|
end
|
111
112
|
|
112
113
|
def process_resources(resource_type, resources, rule)
|
113
|
-
|
114
|
+
resources.each do |resource|
|
115
|
+
comment = build_comment(rule_actions(rule), resource: resource)
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
if options.dry_run
|
118
|
+
puts "\nThe following comment would be posted for the rule '#{rule[:name]}':\n\n"
|
119
|
+
puts ">>>\n#{comment}\n>>>"
|
120
|
+
break
|
121
|
+
end
|
120
122
|
|
121
|
-
resources.each do |resource|
|
122
123
|
network.post_api(options.token, build_post_url(resource_type, resource), comment)
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
|
-
def build_comment(actions)
|
127
|
+
def build_comment(actions, resource: nil)
|
127
128
|
CommandBuilders::CommentCommandBuilder.new(
|
128
129
|
[
|
129
|
-
actions[:comment],
|
130
|
+
CommandBuilders::CommentBodyBuilder.new(actions[:comment], resource: resource).build_command,
|
130
131
|
CommandBuilders::LabelCommandBuilder.new(actions[:labels]).build_command,
|
131
132
|
CommandBuilders::RemoveLabelCommandBuilder.new(actions[:remove_labels]).build_command,
|
132
133
|
CommandBuilders::CcCommandBuilder.new(actions[:mention]).build_command,
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/gitlab/triage.rb
|
120
120
|
- lib/gitlab/triage/command_builders/base_command_builder.rb
|
121
121
|
- lib/gitlab/triage/command_builders/cc_command_builder.rb
|
122
|
+
- lib/gitlab/triage/command_builders/comment_body_builder.rb
|
122
123
|
- lib/gitlab/triage/command_builders/comment_command_builder.rb
|
123
124
|
- lib/gitlab/triage/command_builders/label_command_builder.rb
|
124
125
|
- lib/gitlab/triage/command_builders/remove_label_command_builder.rb
|