gitlab-triage 1.7.1 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c67fa47a534d7f13d781966693423d4916292ec9924e4913492e63eb00a5f5a
4
- data.tar.gz: ecd0946de096e97fd73ca3b7aa243842b3bf2cdccff9b6746b4034893789d672
3
+ metadata.gz: 87679dea12bb15870422da7cbb53b8f884a9be57adc31121f630f627cf623c31
4
+ data.tar.gz: 174f84a54229c2149676585d549c2e5d632e1af08e8d20b06185cf5a25658ccb
5
5
  SHA512:
6
- metadata.gz: cc9bc7902d7e3e96186d2f2593c76ef64bd74005857548e6b8d5014a70e3be1d75447083b06de4e7bb923651b0d9696029dfdf64ef3011672fc8a1ffbb4d8ca4
7
- data.tar.gz: aa02ac6fbefebc75589e4da546c52e48150408aebdacd34fc83f0cf24a373d19c3e63de52cbfba6847bcc778b285ba21e9c4ea037d886d36122998d2bebbf9d7
6
+ metadata.gz: 38d5da0ee38003cb2721661ec274fd29b8e5d6ad5c13ee71fa7b10568a27e54ee8fd8542ea22006e7f37122bf13324f4466ce7eb965dab785133be2e6d10e0ef
7
+ data.tar.gz: 5de453ccaa7ace322a77a318f267421336a38ade1986a83b3e0a4611edbb8f6f6990272dc130872a47c9c394f337f53699cb96a097b7b021dbdeff250e16eb5c
data/.gitignore CHANGED
@@ -6,7 +6,6 @@
6
6
  /Gemfile.lock
7
7
  /_yardoc/
8
8
  /coverage/
9
- /doc/
10
9
  /pkg/
11
10
  /spec/reports/
12
11
  /tmp/
@@ -1,49 +1,67 @@
1
- image: ruby:2.6
2
-
3
1
  stages:
4
2
  - prepare
5
3
  - test
6
4
  - triage
5
+ - release
7
6
 
8
- .default-only:
9
- only:
10
- refs:
11
- - master
12
- - merge_requests
13
- - tags
14
-
15
- .default-before_script:
7
+ default:
8
+ image: ruby:2.7
9
+ tags:
10
+ - gitlab-org
11
+ cache:
12
+ key:
13
+ files:
14
+ - Gemfile
15
+ - gitlab-triage.gemspec
16
+ paths:
17
+ - vendor/ruby
18
+ - Gemfile.lock
19
+ policy: pull
16
20
  before_script:
21
+ - ruby --version
17
22
  - gem install bundler --no-document --version 2.0.2
18
- - bundle install --jobs $(nproc) --retry 3 --quiet
23
+ - bundle --version
24
+ - bundle install --jobs $(nproc) --path=vendor --retry 3 --quiet
25
+ - bundle check
26
+
27
+ workflow:
28
+ rules:
29
+ # For merge requests, create a pipeline.
30
+ - if: '$CI_MERGE_REQUEST_IID'
31
+ # For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
32
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
33
+ # For tags, create a pipeline.
34
+ - if: '$CI_COMMIT_TAG'
35
+
36
+ .use-docker-in-docker:
37
+ image: docker:${DOCKER_VERSION}
38
+ services:
39
+ - docker:${DOCKER_VERSION}-dind
40
+ variables:
41
+ DOCKER_DRIVER: overlay2
42
+ DOCKER_HOST: tcp://docker:2375
43
+ DOCKER_TLS_CERTDIR: ""
44
+ tags:
45
+ # See https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/7019 for tag descriptions
46
+ - gitlab-org-docker
19
47
 
20
48
  ###################
21
49
  ## Prepare stage ##
22
50
  ###################
23
51
  setup-test-env:
24
- extends: .default-only
25
52
  stage: prepare
26
53
  script:
27
- - ruby --version
28
- - gem install bundler --no-document
29
- - bundle --version
30
- - bundle install --clean --jobs $(nproc) --path=vendor --retry=3 --quiet
31
- - bundle check
54
+ - echo "Setup done!"
32
55
  cache:
33
- key: "$CI_JOB_NAME-ruby-2.6"
34
- paths:
35
- - vendor/ruby
36
- - Gemfile.lock
56
+ policy: pull-push
37
57
  artifacts:
38
58
  paths:
39
- - vendor/ruby
40
59
  - Gemfile.lock
41
60
 
42
61
  ################
43
62
  ## Test stage ##
44
63
  ################
45
64
  rubocop:
46
- extends: [".default-only", ".default-before_script"]
47
65
  stage: test
48
66
  needs: ["setup-test-env"]
49
67
  dependencies: ["setup-test-env"]
@@ -55,20 +73,15 @@ rubocop:
55
73
  - .cache/rubocop_cache/
56
74
 
57
75
  # We need to copy this job's definition from the Code-Quality.gitlab-ci.yml
58
- # template because `only` is set without `refs`, so it takes precedence over `.default-only`.
76
+ # template because `only` is set without `refs`, so it takes precedence over default workflow rules.
59
77
  # See https://gitlab.com/gitlab-org/gitlab-ce/issues/66767.
60
78
  code_quality:
61
- extends: .default-only
62
- needs: ["setup-test-env"]
63
- dependencies: ["setup-test-env"]
79
+ extends: .use-docker-in-docker
64
80
  stage: test
65
- image: docker:stable
66
81
  allow_failure: true
67
- services:
68
- - docker:stable-dind
69
82
  variables:
70
- DOCKER_DRIVER: overlay2
71
83
  DOCKER_TLS_CERTDIR: ""
84
+ before_script: []
72
85
  script:
73
86
  - |
74
87
  if ! docker info &>/dev/null; then
@@ -85,14 +98,9 @@ code_quality:
85
98
  reports:
86
99
  codequality: gl-code-quality-report.json
87
100
  expire_in: 1 week
88
- except:
89
- variables:
90
- - $CODE_QUALITY_DISABLED
91
101
 
92
102
  specs:
93
- extends: [".default-only", ".default-before_script"]
94
103
  needs: ["setup-test-env"]
95
- dependencies: ["setup-test-env"]
96
104
  stage: test
97
105
  script:
98
106
  - bundle exec rake spec
@@ -101,12 +109,13 @@ specs:
101
109
  ## Triage stage ##
102
110
  ##################
103
111
  dry-run:gitlab-triage:
104
- extends: [".default-only", ".default-before_script"]
105
112
  needs: ["setup-test-env"]
106
- dependencies: ["setup-test-env"]
107
113
  stage: triage
108
114
  script:
109
- - bundle exec rake install:local
115
+ - bundle exec rake build
116
+ - gem install pkg/*.gem
117
+ - which gitlab-triage
118
+ - gitlab-triage --version
110
119
  - gitlab-triage --help
111
120
  - gitlab-triage --init
112
121
  - gitlab-triage --dry-run --debug --token $API_TOKEN --source-id $CI_PROJECT_PATH
@@ -114,4 +123,30 @@ dry-run:gitlab-triage:
114
123
  # This job requires allows to override the `CI_PROJECT_PATH` variable when triggered.
115
124
  dry-run:custom:
116
125
  extends: dry-run:gitlab-triage
117
- when: manual
126
+ rules:
127
+ - when: manual
128
+ allow_failure: true
129
+
130
+ ###################
131
+ ## Release stage ##
132
+ ###################
133
+ release:
134
+ stage: release
135
+ rules:
136
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
137
+ changes: ["lib/gitlab/triage/version.rb"]
138
+ - if: '$CI_MERGE_REQUEST_TITLE =~ /RELEASE/'
139
+ when: manual
140
+ before_script: []
141
+ script:
142
+ - version=$(ruby -r ./lib/gitlab/triage/version -e 'puts Gitlab::Triage::VERSION' | tr -d "\n")
143
+ - tag="v${version}"
144
+ - message="Version ${version}."
145
+ # TODO: Add release notes from the Release MR?
146
+ - 'curl --request POST --header "PRIVATE-TOKEN: ${API_TOKEN}" -d "tag_name=${tag}" -d "ref=${CI_COMMIT_SHA}" -d "message=${message}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/tags"'
147
+ - gem build gitlab-triage.gemspec
148
+ - gem push "gitlab-triage-${version}.gem"
149
+ artifacts:
150
+ paths:
151
+ - gitlab-triage*.gem
152
+ expire_in: 30 days
@@ -0,0 +1,35 @@
1
+ <!-- Replace `v4.5.0` with the previous release here, and `e18d76b309e42888759c1effe96767f13e34ae55`
2
+ with the latest commit from https://gitlab.com/gitlab-org/gitlab-triage/commits/master that will be included in the release. -->
3
+ - Diff: https://gitlab.com/gitlab-org/gitlab-triage/compare/v4.5.0...e18d76b309e42888759c1effe96767f13e34ae55
4
+
5
+ - Release notes:
6
+
7
+ <!-- Keep the sections order but remove the empty sections -->
8
+
9
+ ```markdown
10
+ ### New scenarios and scenario updates
11
+
12
+ - !aaa <Title of the aaa MR>.
13
+
14
+ ### Fixes
15
+
16
+ - !bbb <Title of the bbb MR>.
17
+
18
+ ### Doc changes
19
+
20
+ - !ccc <Title of the ccc MR>.
21
+
22
+ ### Other changes (CI, backstage)
23
+
24
+ - !ddd <Title of the ddd MR>.
25
+ ```
26
+
27
+ - Checklist before merging:
28
+ - [ ] Diff link is up-to-date.
29
+ - [ ] Based on the diff, `lib/gitlab/triage/version.rb` is updated, according to [SemVer](https://semver.org).
30
+ - [ ] Release notes are accurate.
31
+
32
+ - Checklist after merging:
33
+ - [ ] [Update the release notes for the newly created tag](docs/release_process.md#how-to).
34
+
35
+ /label ~"Engineering Productivity" ~"ep::triage"
@@ -11,3 +11,6 @@ AllCops:
11
11
 
12
12
  Rails/Output:
13
13
  Enabled: false
14
+
15
+ Metrics/LineLength:
16
+ Max: 152
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'gitlab-styles', '~> 3.0'
7
+ gem 'gitlab-styles', '~> 3.3.0'
8
8
  end
data/README.md CHANGED
@@ -58,7 +58,7 @@ resource_rules:
58
58
  interval: 5
59
59
  state: opened
60
60
  labels:
61
- - No Label
61
+ - None
62
62
  limits:
63
63
  most_recent: 50
64
64
  actions:
@@ -66,6 +66,7 @@ resource_rules:
66
66
  - needs attention
67
67
  mention:
68
68
  - markglenfletcher
69
+ move: gitlab-org/backlog
69
70
  comment: |
70
71
  {{author}} This issue is unlabelled after 5 days. It needs attention. Please take care of this before the end of #{2.days.from_now.strftime('%Y-%m-%d')}
71
72
  summarize:
@@ -85,9 +86,27 @@ resource_rules:
85
86
  /label ~"needs attention"
86
87
  merge_requests:
87
88
  rules:
88
- []
89
+ - name: My policy
90
+ conditions:
91
+ state: opened
92
+ labels:
93
+ - None
94
+ limits:
95
+ most_recent: 50
96
+ actions:
97
+ labels:
98
+ - needs attention
99
+ comment_type: thread
100
+ comment: |
101
+ {{author}} This issue is unlabelled. Please add one or more labels.
89
102
  ```
90
103
 
104
+ ### Real world example
105
+
106
+ We're enforcing multiple polices with pipeline schedules at [triage-ops](
107
+ https://gitlab.com/gitlab-org/quality/triage-ops), where we're also
108
+ extensively utilizing the [plugins system](#can-i-customize).
109
+
91
110
  ### Fields
92
111
 
93
112
  A policy consists of the following fields:
@@ -210,6 +229,22 @@ conditions:
210
229
  - feature proposal
211
230
  ```
212
231
 
232
+ ###### Predefined special label names
233
+
234
+ Basing on the [issues API](https://docs.gitlab.com/ee/api/issues.html), there
235
+ are two special predefined label names we can use here:
236
+
237
+ * `None`: This indicates that no labels were present
238
+ * `Any`: This indicates that any labels were presented
239
+
240
+ Example:
241
+
242
+ ```yml
243
+ conditions:
244
+ labels:
245
+ - None
246
+ ```
247
+
213
248
  ###### Labels brace expansion
214
249
 
215
250
  We could expand the labels by using brace expansion, which is a pattern
@@ -506,7 +541,9 @@ Available action types:
506
541
  - [`remove_labels` action](#remove-labels-action)
507
542
  - [`status` action](#status-action)
508
543
  - [`mention` action](#mention-action)
544
+ - [`move` action](#move-action)
509
545
  - [`comment` action](#comment-action)
546
+ - [`comment_type` action option](#comment-type-action-option)
510
547
  - [`summarize` action](#summarize-action)
511
548
 
512
549
  ##### Labels action
@@ -572,6 +609,19 @@ actions:
572
609
  - markglenfletcher
573
610
  ```
574
611
 
612
+ ##### Move action
613
+
614
+ Moves an issue (merge request is not supported yet) to the specified project.
615
+
616
+ Accepts a string containing the target project path.
617
+
618
+ Example:
619
+
620
+ ```yml
621
+ actions:
622
+ move: target/project_path
623
+ ```
624
+
575
625
  ##### Comment action
576
626
 
577
627
  Adds a comment to the resource.
@@ -619,6 +669,26 @@ actions:
619
669
  {{author}} Are you still interested in finishing this merge request?
620
670
  ```
621
671
 
672
+ ##### Comment type action option
673
+
674
+ Determines the type of comment to be added to the resource.
675
+
676
+ The following comment types are supported:
677
+
678
+ - `comment` (default): creates a regular comment on the resource
679
+ - `thread`: starts a resolvable thread (discussion) on the resource
680
+
681
+ For merge requests, if `comment_type` is set to `thread`, we can also configure that [all threads should be resolved before merging](https://docs.gitlab.com/ee/user/discussions/#only-allow-merge-requests-to-be-merged-if-all-threads-are-resolved), therefore this comment can prevent it from merging.
682
+
683
+ Example:
684
+
685
+ ```yml
686
+ actions:
687
+ comment_type: thread
688
+ comment: |
689
+ {{author}} Are you still interested in finishing this merge request?
690
+ ```
691
+
622
692
  ###### Harnessing Quick Actions
623
693
 
624
694
  [GitLab's quick actions feature](https://docs.gitlab.com/ce/user/project/quick_actions.html) is available in Core.
@@ -930,6 +1000,7 @@ Usage: gitlab-triage [options]
930
1000
  -r, --require [string] Require a file before performing
931
1001
  -d, --debug Print debug information
932
1002
  -h, --help Print help message
1003
+ --all-projects Process all projects visible to `--token`
933
1004
  --init Initialize the project with a policy file
934
1005
  --init-ci Initialize the project with a .gitlab-ci.yml file
935
1006
  ```
@@ -948,6 +1019,14 @@ Triaging against a whole group:
948
1019
  gitlab-triage --dry-run --token $API_TOKEN --source-id gitlab-org --source groups
949
1020
  ```
950
1021
 
1022
+ Triaging against an entire instance:
1023
+
1024
+ ```
1025
+ gitlab-triage --dry-run --token $API_TOKEN --all-projects
1026
+ ```
1027
+
1028
+ > **Note:** The `--all-projects` option will process all resources for all projects visible to the specified `$API_TOKEN`
1029
+
951
1030
  #### Running on GitLab CI pipeline
952
1031
 
953
1032
  You can enforce policies using a scheduled pipeline:
@@ -1030,3 +1109,7 @@ resource_rules:
1030
1109
  ### Contributing
1031
1110
 
1032
1111
  Please refer to the [Contributing Guide](CONTRIBUTING.md).
1112
+
1113
+ ## Release Process
1114
+
1115
+ Please refer to the [Release Process](docs/release_process.md).
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
- f.match(%r{^(test|spec|features)/})
16
+ f.match(%r{^(docs|test|spec|features)/})
17
17
  end
18
18
  spec.bindir = 'bin'
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -7,6 +7,7 @@ require_relative '../command_builders/label_command_builder'
7
7
  require_relative '../command_builders/remove_label_command_builder'
8
8
  require_relative '../command_builders/cc_command_builder'
9
9
  require_relative '../command_builders/status_command_builder'
10
+ require_relative '../command_builders/move_command_builder'
10
11
 
11
12
  module Gitlab
12
13
  module Triage
@@ -43,6 +44,7 @@ module Gitlab
43
44
  CommandBuilders::LabelCommandBuilder.new(policy.actions[:labels]).build_command,
44
45
  CommandBuilders::RemoveLabelCommandBuilder.new(policy.actions[:remove_labels]).build_command,
45
46
  CommandBuilders::CcCommandBuilder.new(policy.actions[:mention]).build_command,
47
+ CommandBuilders::MoveCommandBuilder.new(policy.actions[:move]).build_command,
46
48
  CommandBuilders::StatusCommandBuilder.new(policy.actions[:status]).build_command
47
49
  ]
48
50
  ).build_command
@@ -61,13 +63,24 @@ module Gitlab
61
63
  source_id: resource[:project_id],
62
64
  resource_type: policy.type,
63
65
  resource_id: resource['iid'],
64
- sub_resource_type: 'notes'
66
+ sub_resource_type: sub_resource_type
65
67
  ).build
66
68
 
67
69
  puts Gitlab::Triage::UI.debug "post_url: #{post_url}" if network.options.debug
68
70
 
69
71
  post_url
70
72
  end
73
+
74
+ def sub_resource_type
75
+ case type = policy.actions[:comment_type]
76
+ when 'comment', nil # nil is default
77
+ 'notes'
78
+ when 'thread'
79
+ 'discussions'
80
+ else
81
+ raise ArgumentError, "Unknown comment type: #{type}"
82
+ end
83
+ end
71
84
  end
72
85
  end
73
86
  end
@@ -0,0 +1,19 @@
1
+ require_relative 'base_command_builder'
2
+
3
+ module Gitlab
4
+ module Triage
5
+ module CommandBuilders
6
+ class MoveCommandBuilder < BaseCommandBuilder
7
+ private
8
+
9
+ def slash_command_string
10
+ "/move"
11
+ end
12
+
13
+ def format_item(item)
14
+ item
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/array/wrap'
4
+ require 'cgi'
4
5
 
5
6
  require_relative 'base_command_builder'
6
7
  require_relative '../resource/context'
@@ -76,7 +77,22 @@ module Gitlab
76
77
  template.sub(PLACEHOLDER_REGEX, attribute.to_s)
77
78
  end.join(', ')
78
79
 
79
- comment.gsub("{{#{placeholder}}}", formatted_text)
80
+ escaped_text =
81
+ case placeholder
82
+ when :items
83
+ # We don't need to escape it because it's recursive,
84
+ # which the contents should all be escaped already.
85
+ # Or put it another way, items isn't an attribute
86
+ # retrieved externally. It's a generated value which
87
+ # should be safe to begin with. At some point we
88
+ # may want to make this more distinguishable,
89
+ # separating values from API and values generated.
90
+ formatted_text
91
+ else
92
+ CGI.escape_html(formatted_text)
93
+ end
94
+
95
+ comment.gsub("{{#{placeholder}}}", escaped_text)
80
96
  end
81
97
  end
82
98
 
@@ -38,6 +38,7 @@ module Gitlab
38
38
  @options = options
39
39
  @network_adapter_class = network_adapter_class
40
40
 
41
+ assert_all!
41
42
  assert_project_id!
42
43
  assert_token!
43
44
  require_ruby_files
@@ -66,6 +67,7 @@ module Gitlab
66
67
 
67
68
  def assert_project_id!
68
69
  return if options.source_id
70
+ return if options.all
69
71
 
70
72
  raise ArgumentError, 'A project_id is needed (pass it with the `--source-id` option)!'
71
73
  end
@@ -76,6 +78,11 @@ module Gitlab
76
78
  raise ArgumentError, 'A token is needed (pass it with the `--token` option)!'
77
79
  end
78
80
 
81
+ def assert_all!
82
+ raise ArgumentError, '--all-projects option cannot be used in conjunction with --source and --source-id option!' if
83
+ options.all && (options.source || options.source_id)
84
+ end
85
+
79
86
  def require_ruby_files
80
87
  options.require_files.each(&method(:require))
81
88
  end
@@ -196,12 +203,32 @@ module Gitlab
196
203
  raise "Unknown resource type: #{resource[:type]}"
197
204
  end
198
205
  end
199
- results << Filters::VotesConditionsFilter.new(resource, conditions[:upvotes]).calculate if conditions[:upvotes]
200
- results << Filters::ForbiddenLabelsConditionsFilter.new(resource, conditions[:forbidden_labels]).calculate if conditions[:forbidden_labels]
201
- results << Filters::NoAdditionalLabelsConditionsFilter.new(resource, conditions.fetch(:labels) { [] }).calculate if conditions[:no_additional_labels]
202
- results << Filters::AuthorMemberConditionsFilter.new(resource, conditions[:author_member], network).calculate if conditions[:author_member]
203
- results << Filters::AssigneeMemberConditionsFilter.new(resource, conditions[:assignee_member], network).calculate if conditions[:assignee_member]
204
- results << Filters::RubyConditionsFilter.new(resource, conditions, network).calculate if conditions[:ruby]
206
+
207
+ # rubocop:disable Style/IfUnlessModifier
208
+ if conditions[:upvotes]
209
+ results << Filters::VotesConditionsFilter.new(resource, conditions[:upvotes]).calculate
210
+ end
211
+
212
+ if conditions[:forbidden_labels]
213
+ results << Filters::ForbiddenLabelsConditionsFilter.new(resource, conditions[:forbidden_labels]).calculate
214
+ end
215
+
216
+ if conditions[:no_additional_labels]
217
+ results << Filters::NoAdditionalLabelsConditionsFilter.new(resource, conditions.fetch(:labels) { [] }).calculate
218
+ end
219
+
220
+ if conditions[:author_member]
221
+ results << Filters::AuthorMemberConditionsFilter.new(resource, conditions[:author_member], network).calculate
222
+ end
223
+
224
+ if conditions[:assignee_member]
225
+ results << Filters::AssigneeMemberConditionsFilter.new(resource, conditions[:assignee_member], network).calculate
226
+ end
227
+
228
+ if conditions[:ruby]
229
+ results << Filters::RubyConditionsFilter.new(resource, conditions, network).calculate
230
+ end
231
+ # rubocop:enable Style/IfUnlessModifier
205
232
 
206
233
  results.all?
207
234
  end
@@ -235,6 +262,7 @@ module Gitlab
235
262
 
236
263
  UrlBuilders::UrlBuilder.new(
237
264
  network_options: options,
265
+ all: options.all,
238
266
  source: options.source,
239
267
  source_id: options.source_id,
240
268
  resource_type: resource_type,
@@ -1 +1 @@
1
- require 'gitlab/triage/errors/network'
1
+ require_relative 'errors/network'
@@ -23,6 +23,10 @@ module Gitlab
23
23
  options.policies_files << value
24
24
  end
25
25
 
26
+ opts.on('--all-projects', 'Process all projects the token has access to') do |value|
27
+ options.all = value
28
+ end
29
+
26
30
  opts.on('-s', '--source [type]', [:projects, :groups], 'The source type between [ projects or groups ], default value: projects') do |value|
27
31
  options.source = value
28
32
  end
@@ -59,6 +63,12 @@ module Gitlab
59
63
  exit # rubocop:disable Rails/Exit
60
64
  end
61
65
 
66
+ opts.on('-v', '--version', 'Print version') do
67
+ require_relative 'version'
68
+ $stdout.puts Gitlab::Triage::VERSION
69
+ exit # rubocop:disable Rails/Exit
70
+ end
71
+
62
72
  opts.on('--init', 'Initialize the project with a policy file') do
63
73
  example_path =
64
74
  File.expand_path('../../../support/.triage-policies.example.yml', __dir__)
@@ -3,6 +3,7 @@ module Gitlab
3
3
  Options = Struct.new(
4
4
  :dry_run,
5
5
  :policies_files,
6
+ :all,
6
7
  :source,
7
8
  :source_id,
8
9
  :token,
@@ -17,6 +18,7 @@ module Gitlab
17
18
  # Defaults
18
19
  self.host_url ||= 'https://gitlab.com'
19
20
  self.api_version ||= 'v4'
21
+ self.all ||= false
20
22
  self.source ||= 'projects'
21
23
  self.require_files ||= []
22
24
  self.policies_files ||= Set.new
@@ -6,6 +6,7 @@ module Gitlab
6
6
  @network_options = options.fetch(:network_options)
7
7
  @host_url = @network_options.host_url
8
8
  @api_version = @network_options.api_version
9
+ @all = options.fetch(:all, false)
9
10
  @source = options.fetch(:source, 'projects')
10
11
  @source_id = options.fetch(:source_id)
11
12
  @resource_type = options.fetch(:resource_type, nil)
@@ -15,11 +16,11 @@ module Gitlab
15
16
  end
16
17
 
17
18
  def build
18
- base_url.tap do |url|
19
- url << "/#{@resource_id}" if @resource_id
20
- url << "/#{@sub_resource_type}" if @sub_resource_type
21
- url << params_string if @params
22
- end
19
+ url = base_url
20
+ url << "/#{@resource_id}" if @resource_id
21
+ url << "/#{@sub_resource_type}" if @sub_resource_type
22
+ url << params_string if @params
23
+ url
23
24
  end
24
25
 
25
26
  private
@@ -29,10 +30,10 @@ module Gitlab
29
30
  end
30
31
 
31
32
  def base_url
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
+ url = host_with_api_url
34
+ url << "/#{@source}/#{CGI.escape(@source_id.to_s)}" unless @all
35
+ url << "/#{@resource_type}" if @resource_type
36
+ url
36
37
  end
37
38
 
38
39
  def params_string
@@ -12,7 +12,9 @@ module Gitlab
12
12
  end
13
13
 
14
14
  def validate_required_parameters(value)
15
- raise ArgumentError, "For the limits field, please specify one of: `#{params_limiter_names.join('`, `')}`" unless value.keys.map(&:to_sym).one? { |key| params_limiter_names.include?(key) }
15
+ return if value.keys.one? { |key| params_limiter_names.include?(key.to_sym) }
16
+
17
+ raise ArgumentError, "For the limits field, please specify one of: `#{params_limiter_names.join('`, `')}`"
16
18
  end
17
19
  end
18
20
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gitlab
2
4
  module Triage
3
- VERSION = '1.7.1'.freeze
5
+ VERSION = '1.8.0'
4
6
  end
5
7
  end
@@ -6,10 +6,10 @@ resource_rules:
6
6
  date:
7
7
  attribute: created_at
8
8
  condition: older_than
9
- interval_type: week
9
+ interval_type: weeks
10
10
  interval: 1
11
11
  labels:
12
- - No label
12
+ - None
13
13
  state: opened
14
14
  actions:
15
15
  comment: |
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.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -120,6 +120,7 @@ files:
120
120
  - ".gitignore"
121
121
  - ".gitlab-ci.yml"
122
122
  - ".gitlab/CODEOWNERS"
123
+ - ".gitlab/merge_request_templates/Release.md"
123
124
  - ".rubocop.yml"
124
125
  - CONTRIBUTING.md
125
126
  - Gemfile
@@ -141,6 +142,7 @@ files:
141
142
  - lib/gitlab/triage/command_builders/cc_command_builder.rb
142
143
  - lib/gitlab/triage/command_builders/comment_command_builder.rb
143
144
  - lib/gitlab/triage/command_builders/label_command_builder.rb
145
+ - lib/gitlab/triage/command_builders/move_command_builder.rb
144
146
  - lib/gitlab/triage/command_builders/remove_label_command_builder.rb
145
147
  - lib/gitlab/triage/command_builders/status_command_builder.rb
146
148
  - lib/gitlab/triage/command_builders/text_content_builder.rb
@@ -212,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
214
  - !ruby/object:Gem::Version
213
215
  version: '0'
214
216
  requirements: []
215
- rubygems_version: 3.0.3
217
+ rubygems_version: 3.1.2
216
218
  signing_key:
217
219
  specification_version: 4
218
220
  summary: GitLab triage automation project.