gitlab-dangerfiles 2.5.0 → 2.6.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: 93e497ecb88959ef6d916e995491d4a17644b2875b765a87d1b8dbf2a2e245cd
4
- data.tar.gz: 2060f3bb306e1abf440eb4d2eead9f4a97dd5999d28a691fe119260fcf338b45
3
+ metadata.gz: af398dd6651e65bb4716c5a2c1aee8ee93a9a98c68f4b71f5da3de3d83a2aff2
4
+ data.tar.gz: cb57a546b8f9c15b1c17ebe9fa6936e312c6f0345e74c6778220ceb56b884c6a
5
5
  SHA512:
6
- metadata.gz: 01a447e73d6550265ddf775674190816341bd07f484be816b7583fc3b70427bcfb2b1a0c9aa86b651486bed62953a8e97838c58527eee11af4c169f2633d7d2f
7
- data.tar.gz: f85733f1b015c3170cafc990b0cf84c773ed8532f11e3978b59d21477ad592d8095ff6b46b4a673da98f956c1368ed4a6501e3ae26b62c1d1c534022bbc4b88b
6
+ metadata.gz: 3b4df78cdb34004d811fbd711c251151820382a3ed4de31b26f46e90a8a9f121a2111b2d90de1aeaf390129fccb563bfa679ddc50ef84975a9f6da9ad3aeff6d
7
+ data.tar.gz: b88f6fb0e0e46d5f089651312fe45a7713ab6f732216d744bf8f24515d6471d08696cd1b2ee1b2290c881972b6ef8c5376a68a74d58fd0ec76e7620009074a16
@@ -0,0 +1,13 @@
1
+ ---
2
+ # Settings for generating changelogs using the GitLab API. See
3
+ # https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data for
4
+ # more information.
5
+ categories:
6
+ added: Added
7
+ fixed: Fixed
8
+ changed: Changed
9
+ deprecated: Deprecated
10
+ removed: Removed
11
+ security: Security
12
+ performance: Performance
13
+ other: Other
@@ -1,35 +1,13 @@
1
- <!-- Replace `v4.5.0` with the previous release here, and `e18d76b309e42888759c1effe96767f13e34ae55`
2
- with the latest commit from https://gitlab.com/gitlab-org/gitlab-dangerfiles/commits/master that will be included in the release. -->
3
- - Diff: https://gitlab.com/gitlab-org/gitlab-dangerfiles/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 features and features 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 (tooling, technical debt)
23
-
24
- - !ddd <Title of the ddd MR>.
25
- ```
1
+ <!-- Replace `<NEW_VERSION>` with the previous release here, and `<COMMIT_UPDATING_VERSION>`
2
+ with the latest commit from this merge request. -->
3
+ - Diff: https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/compare/v<NEW_VERSION>...<COMMIT_UPDATING_VERSION>
26
4
 
27
5
  - Checklist before merging:
28
6
  - [ ] Diff link is up-to-date.
29
- - [ ] Based on the diff, `lib/gitlab/dangerfiles/version.rb` is updated, according to [SemVer](https://semver.org).
30
- - [ ] Release notes are accurate.
7
+ - [ ] Based on the diff, `version.rb` is updated, according to [SemVer](https://semver.org).
31
8
 
32
9
  - Checklist after merging:
33
10
  - [ ] [Update the release notes for the newly created tag](docs/release_process.md#how-to).
11
+ - [ ] Check that automatic release notes (generated following the same process as https://docs.gitlab.com/ee/development/changelog.html) are correct.
34
12
 
35
- /label ~"Engineering Productivity" ~"ep::workflow" ~"tooling::workflow" ~tooling ~"Danger bot"
13
+ /label ~"type::maintenance" ~"static code analysis"
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,40 @@
1
+ ## Developer Certificate of Origin and License
2
+
3
+ By contributing to GitLab B.V., you accept and agree to the following terms and
4
+ conditions for your present and future contributions submitted to GitLab B.V.
5
+ Except for the license granted herein to GitLab B.V. and recipients of software
6
+ distributed by GitLab B.V., you reserve all right, title, and interest in and to
7
+ your Contributions.
8
+
9
+ All contributions are subject to the Developer Certificate of Origin and license set out at [docs.gitlab.com/ce/legal/developer_certificate_of_origin](https://docs.gitlab.com/ce/legal/developer_certificate_of_origin).
10
+
11
+ _This notice should stay as the first item in the CONTRIBUTING.md file._
12
+
13
+ ## Code of conduct
14
+
15
+ As contributors and maintainers of this project, we pledge to respect all people
16
+ who contribute through reporting issues, posting feature requests, updating
17
+ documentation, submitting pull requests or patches, and other activities.
18
+
19
+ We are committed to making participation in this project a harassment-free
20
+ experience for everyone, regardless of level of experience, gender, gender
21
+ identity and expression, sexual orientation, disability, personal appearance,
22
+ body size, race, ethnicity, age, or religion.
23
+
24
+ Examples of unacceptable behavior by participants include the use of sexual
25
+ language or imagery, derogatory comments or personal attacks, trolling, public
26
+ or private harassment, insults, or other unprofessional conduct.
27
+
28
+ Project maintainers have the right and responsibility to remove, edit, or reject
29
+ comments, commits, code, wiki edits, issues, and other contributions that are
30
+ not aligned to this Code of Conduct. Project maintainers who do not follow the
31
+ Code of Conduct may be removed from the project team.
32
+
33
+ This code of conduct applies both within project spaces and in public spaces
34
+ when an individual is representing the project or its community.
35
+
36
+ Instances of abusive, harassing, or otherwise unacceptable behavior can be
37
+ reported by emailing contact@gitlab.com.
38
+
39
+ This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org), version 1.1.0,
40
+ available at [https://contributor-covenant.org/version/1/1/0/](https://contributor-covenant.org/version/1/1/0/).
data/Dangerfile CHANGED
@@ -1,10 +1,5 @@
1
1
  require_relative "lib/gitlab-dangerfiles"
2
2
 
3
- # Get an instance of Gitlab::Dangerfiles
4
- gitlab_dangerfiles = Gitlab::Dangerfiles::Engine.new(self)
5
-
6
- # Import all plugins from the gem
7
- gitlab_dangerfiles.import_plugins
8
-
9
- # Import all rules from the gem
10
- gitlab_dangerfiles.import_dangerfiles
3
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
4
+ dangerfiles.import_defaults
5
+ end
data/README.md CHANGED
@@ -26,22 +26,45 @@ $ gem install gitlab-dangerfiles
26
26
 
27
27
  ### Importing plugins and rules
28
28
 
29
- In your project's `Dangerfile`, add the following two line to import the plugins and rules from this gem:
29
+ In your project's `Dangerfile`, add the following to import the plugins and rules from this gem:
30
30
 
31
31
  ```ruby
32
32
  require 'gitlab-dangerfiles'
33
33
 
34
- # Get an instance of Gitlab::Dangerfiles
35
- gitlab_dangerfiles = Gitlab::Dangerfiles::Engine.new(self)
34
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
35
+ # Import all plugins from the gem
36
+ dangerfiles.import_plugins
36
37
 
37
- # Import all plugins from the gem
38
- gitlab_dangerfiles.import_plugins
38
+ # Import all rules from the gem
39
+ dangerfiles.import_dangerfiles
39
40
 
40
- # Import all rules from the gem
41
- gitlab_dangerfiles.import_dangerfiles
41
+ # Or import only a subset of rules
42
+ dangerfiles.import_dangerfiles(only: %w[changes_size])
42
43
 
43
- # Or import a subset of rules from the gem
44
- gitlab_dangerfiles.import_dangerfiles(rules: [:changes_size])
44
+ # Or import all rules except a subset of rules
45
+ dangerfiles.import_dangerfiles(except: %w[commit_messages])
46
+
47
+ # Or import only a subset of rules, except a subset of rules
48
+ dangerfiles.import_dangerfiles(only: %w[changes_size], except: %w[commit_messages])
49
+ end
50
+ ```
51
+
52
+ For simple projects such as libraries, you can use the convenience method `import_defaults`:
53
+
54
+ ```ruby
55
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
56
+ # Imports all plugins, rules and the default reviewer roulette
57
+ dangerfiles.import_defaults
58
+ end
59
+ ```
60
+
61
+ You may optionally pass a project name; by default, `ENV['CI_PROJECT_NAME']` will be used:
62
+
63
+ ```ruby
64
+ Gitlab::Dangerfiles.for_project(self, 'my-project') do |dangerfiles|
65
+ # Imports all plugins, rules and the default reviewer roulette
66
+ dangerfiles.import_defaults
67
+ end
45
68
  ```
46
69
 
47
70
  ### Plugins
@@ -53,6 +76,20 @@ Danger plugins are located under `lib/danger/plugins`.
53
76
 
54
77
  For the full documentation about the plugins, please see https://www.rubydoc.info/gems/gitlab-dangerfiles.
55
78
 
79
+ ### Configuration
80
+
81
+ Default configuration can be overriden in the form `helper.config.CONFIG_NAME = NEW_VALUE` (`CONFIG_NAME` being a value configuration key).
82
+
83
+ Alternatively, you can also get/set configuration on the engine directly via `Gitlab::Dangerfiles::Engine#config`.
84
+
85
+ #### Available general configurations
86
+
87
+ - `project_name`: The project name. Currently used by the Roulette plugin to fetch relevant
88
+ reviewers/maintainers based on the project name. Default to `ENV["CI_PROJECT_NAME"]`.
89
+ - `files_to_category`: A hash of the form `{ filename_regex => categories, [filename_regex, changes_regex] => categories }`.
90
+ `filename_regex` is the regex pattern to match file names. `changes_regex` is the regex pattern to
91
+ match changed lines in files that match `filename_regex`. Used in `helper.changes_by_category`, `helper.changes`, and `helper.categories_for_file`.
92
+
56
93
  ### Rules
57
94
 
58
95
  Danger rules are located under `lib/danger/rules`.
@@ -72,6 +109,21 @@ Danger rules are located under `lib/danger/rules`.
72
109
  - `max_commits_count`: The maximum number of allowed non-squashed/non-fixup commits for a given MR.
73
110
  A warning is triggered if the MR has more commits.
74
111
 
112
+ ### Reviewer Roulette
113
+
114
+ The library includes a simplified default reviewer roulette that you can use in your
115
+ project. To use it in your project, perform the following steps:
116
+
117
+ 1. If not yet done, create a `Dangerfile` at the top-level of your project. Refer to [Usage](#usage) to
118
+ see how to set it up.
119
+ 1. When using the default roulette, use `import_defaults` or import it manually when setting
120
+ up the gitlab-dangerfiles instance:
121
+ ```ruby
122
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
123
+ dangerfiles.import_dangerfiles(only: %w[simple_roulette])
124
+ end
125
+ ```
126
+
75
127
  ## Documentation
76
128
 
77
129
  Latest documentation can be found at <https://www.rubydoc.info/gems/gitlab-dangerfiles>.
@@ -175,7 +175,7 @@ module Danger
175
175
  #
176
176
  # @return [{Symbol => Array<String>}] a hash of the type +{ category1: ["file1", "file2"], category2: ["file3", "file4"] }+
177
177
  # using filename regex (+filename_regex+) and specific change regex (+changes_regex+) from the given +categories+ hash.
178
- def changes_by_category(categories)
178
+ def changes_by_category(categories = [])
179
179
  all_changed_files.each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash|
180
180
  categories_for_file(file, categories).each { |category| hash[category] << file }
181
181
  end
@@ -187,7 +187,7 @@ module Danger
187
187
  #
188
188
  # @return [Gitlab::Dangerfiles::Changes] a +Gitlab::Dangerfiles::Changes+ object that represents the changes of an MR
189
189
  # using filename regex (+filename_regex+) and specific change regex (+changes_regex+) from the given +categories+ hash.
190
- def changes(categories)
190
+ def changes(categories = [])
191
191
  Gitlab::Dangerfiles::Changes.new([]).tap do |changes|
192
192
  added_files.each do |file|
193
193
  categories_for_file(file, categories).each { |category| changes << Gitlab::Dangerfiles::Change.new(file, :added, category) }
@@ -212,14 +212,17 @@ module Danger
212
212
  end
213
213
 
214
214
  # @param filename [String] A file name.
215
- # @param categories [{Regexp => Array<Symbol>}, {Array<Regexp> => Array<Symbol>}] A hash of the form +{ filename_regex => categories, [filename_regex, changes_regex] => categories }+.
216
- # +filename_regex+ is the regex pattern to match file names. +changes_regex+ is the regex pattern to
217
- # match changed lines in files that match +filename_regex+
215
+ # @param files_to_category [{Regexp => Array<Symbol>}, {Array<Regexp> => Array<Symbol>}] A hash of the form +{ filename_regex => categories, [filename_regex, changes_regex] => categories }+.
216
+ # +filename_regex+ is the regex pattern to match file names. +changes_regex+ is the regex pattern to
217
+ # match changed lines in files that match +filename_regex+
218
218
  #
219
219
  # @return [Array<Symbol>] the categories a file is in, e.g., +[:frontend]+, +[:backend]+, or +%i[frontend tooling]+
220
220
  # using filename regex (+filename_regex+) and specific change regex (+changes_regex+) from the given +categories+ hash.
221
- def categories_for_file(filename, categories)
222
- _, categories = categories.find do |key, _|
221
+ def categories_for_file(filename, files_to_category = [])
222
+ files_to_category = Array(files_to_category).compact
223
+ files_to_category = helper.config.files_to_category if files_to_category.empty?
224
+
225
+ _, categories = files_to_category.find do |key, _|
223
226
  filename_regex, changes_regex = Array(key)
224
227
 
225
228
  found = filename_regex.match?(filename)
@@ -33,8 +33,8 @@ module Danger
33
33
  # @param timezone_experiment [Boolean] Whether to select reviewers based in timezone or not.
34
34
  #
35
35
  # @return [Array<Spin>]
36
- def spin(project, categories = [nil], timezone_experiment: false)
37
- project = project.downcase
36
+ def spin(project = nil, categories = [nil], timezone_experiment: false)
37
+ project = (project || helper.config.project_name).downcase
38
38
  categories = categories.map { |category| category&.downcase }
39
39
 
40
40
  spins = categories.sort_by(&:to_s).map do |category|
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ PROJECT_NAME = helper.config.project_name
4
+
5
+ MESSAGE = <<MARKDOWN
6
+ ## Reviewer roulette
7
+
8
+ Changes that require review have been detected! A merge request is normally
9
+ reviewed by both a reviewer and a maintainer in its primary category and by a
10
+ maintainer in all other categories.
11
+ MARKDOWN
12
+
13
+ TABLE_MARKDOWN = <<MARKDOWN
14
+
15
+ To spread load more evenly across eligible reviewers, Danger has picked a candidate for each
16
+ review slot. Feel free to
17
+ [override these selections](https://about.gitlab.com/handbook/engineering/projects/##{PROJECT_NAME})
18
+ if you think someone else would be better-suited.
19
+
20
+ To read more on how to use the reviewer roulette, please take a look at the
21
+ [Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
22
+ and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).
23
+
24
+ Once you've decided who will review this merge request, mention them as you
25
+ normally would! Danger does not automatically notify them for you.
26
+
27
+ | Reviewer | Maintainer |
28
+ | -------- | ---------- |
29
+ MARKDOWN
30
+
31
+ def note_for_spins_role(spins, role)
32
+ spins.each do |spin|
33
+ note = note_for_spin_role(spin, role)
34
+
35
+ return note if note
36
+ end
37
+
38
+ 'No %{role} available' % { role: role }
39
+ end
40
+
41
+ def note_for_spin_role(spin, role)
42
+ spin.public_send(role)&.markdown_name(author: roulette.team_mr_author)
43
+ end
44
+
45
+ def markdown_row_for_spins(spins_array)
46
+ reviewer_note = note_for_spins_role(spins_array, :reviewer)
47
+ maintainer_note = note_for_spins_role(spins_array, :maintainer)
48
+
49
+ "#{reviewer_note} | #{maintainer_note} |"
50
+ end
51
+
52
+ if helper.changes.any?
53
+ random_roulette_spins = roulette.spin
54
+
55
+ rows = random_roulette_spins.map do |spin|
56
+ markdown_row_for_spins([spin])
57
+ end
58
+
59
+ markdown(MESSAGE)
60
+ markdown(TABLE_MARKDOWN + rows.join("\n")) unless rows.empty?
61
+ end
@@ -3,6 +3,16 @@
3
3
  module Gitlab
4
4
  module Dangerfiles
5
5
  class Config
6
+ # @!attribute project_name
7
+ # @return [String] the project name. Currently used by the Roulette plugin to fetch relevant reviewers/maintainers based on the project name. Default to +ENV["CI_PROJECT_NAME"]+.
8
+ attr_accessor :project_name
9
+
10
+ # @!attribute files_to_category
11
+ # @return [{Regexp => Array<Symbol>}, {Array<Regexp> => Array<Symbol>}] A hash of the form +{ filename_regex => categories, [filename_regex, changes_regex] => categories }+.
12
+ # +filename_regex+ is the regex pattern to match file names. +changes_regex+ is the regex pattern to
13
+ # match changed lines in files that match +filename_regex+. Used in `helper.changes_by_category`, `helper.changes`, and `helper.categories_for_file`.
14
+ attr_accessor :files_to_category
15
+
6
16
  # @!attribute code_size_thresholds
7
17
  # @return [{ high: Integer, medium: Integer }] a hash of the form +{ high: 42, medium: 12 }+ where +:high+ is the lines changed threshold which triggers an error, and +:medium+ is the lines changed threshold which triggers a warning. Also, see +DEFAULT_CHANGES_SIZE_THRESHOLDS+ for the format of the hash.
8
18
  attr_accessor :code_size_thresholds
@@ -15,6 +25,8 @@ module Gitlab
15
25
  DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT = 10
16
26
 
17
27
  def initialize
28
+ @files_to_category = []
29
+ @project_name = ENV["CI_PROJECT_NAME"]
18
30
  @code_size_thresholds = DEFAULT_CHANGES_SIZE_THRESHOLDS
19
31
  @max_commits_count = DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT
20
32
  end
@@ -116,11 +116,10 @@ module Gitlab
116
116
 
117
117
  area && labels.any?("devops::#{area.downcase}") if kind == :reviewer
118
118
  when :tooling, :engineering_productivity # Deprecated as of 2.3.0 in favor of tooling
119
- return false unless role[/Engineering Productivity/]
120
- return true if kind == :reviewer
121
- return true if capabilities(project).include?("#{kind} engineering_productivity")
119
+ return true if capabilities(project).include?("#{kind} #{category}")
120
+ return false if kind == :maintainer
122
121
 
123
- capabilities(project).include?("#{kind} backend")
122
+ capabilities(project).include?("#{kind} backend") # fallback to backend reviewer
124
123
  when :integrations_be
125
124
  kind == :reviewer &&
126
125
  role.match?(/Backend Engineer.+Ecosystem:Integrations/)
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Dangerfiles
3
- VERSION = "2.5.0"
3
+ VERSION = "2.6.0"
4
4
  end
5
5
  end
@@ -13,8 +13,24 @@ module Gitlab
13
13
  commit_messages
14
14
  ].freeze
15
15
  CI_ONLY_RULES = %w[
16
+ simple_roulette
16
17
  ].freeze
17
18
 
19
+ # Utility method to construct a [Gitlab::Dangerfiles::Engine] instance,
20
+ # which is yielded to the given block.
21
+ #
22
+ # @param dangerfile [Danger::Dangerfile] A +Danger::Dangerfile+ object.
23
+ # @param project_name An option string to set the project name. Defaults to +ENV['CI_PROJECT_NAME']+.
24
+ #
25
+ # @return [Gitlab::Dangerfiles::Engine]
26
+ def self.for_project(dangerfile, project_name = nil)
27
+ Engine.new(dangerfile).tap do |engine|
28
+ engine.config.project_name = project_name if project_name
29
+
30
+ yield engine
31
+ end
32
+ end
33
+
18
34
  # This class provides utility methods to import plugins and dangerfiles easily.
19
35
  class Engine
20
36
  # @param dangerfile [Danger::Dangerfile] A +Danger::Dangerfile+ object.
@@ -32,35 +48,66 @@ module Gitlab
32
48
  #
33
49
  # @example
34
50
  # # In your main Dangerfile:
35
- # dangerfiles = Gitlab::Dangerfiles::Engine.new(self)
36
- #
37
- # # Import all plugins
38
- # dangerfiles.import_plugins
51
+ # Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
52
+ # dangerfiles.import_plugins
53
+ # end
39
54
  def import_plugins
40
55
  danger_plugin.import_plugin(File.expand_path("../danger/plugins/*.rb", __dir__))
41
56
  end
42
57
 
43
58
  # Import available Dangerfiles.
44
59
  #
60
+ # @deprecated
45
61
  # @param rules [Symbol, Array<String>] Can be either +:all+ (default) to import all rules,
46
62
  # or an array of rules.
47
63
  # Available rules are: +changes_size+.
48
64
  #
49
- # @example
50
- # # In your main Dangerfile:
51
- # dangerfiles = Gitlab::Dangerfiles::Engine.new(self)
65
+ # @param only [Symbol, Array<String>] An array of rules to import (defaults to all rules).
66
+ # Available rules are: +changes_size+.
52
67
  #
53
- # # Import all rules
54
- # dangerfiles.import_dangerfiles
68
+ # @param except [Symbol, Array<String>] An array of rules to not import (defaults to []).
69
+ # Available rules are: +changes_size+.
55
70
  #
56
- # # Or import only a subset of rules
57
- # dangerfiles.import_dangerfiles(rules: %w[changes_size])
58
- def import_dangerfiles(rules: :all)
59
- filtered_rules(rules).each do |rule|
71
+ # @example
72
+ # # In your main Dangerfile:
73
+ # Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
74
+ # # Import all rules
75
+ # dangerfiles.import_dangerfiles
76
+ # # Or import only a subset of rules
77
+ # dangerfiles.import_dangerfiles(only: %w[changes_size])
78
+ # # Or import all rules except a subset of rules
79
+ # dangerfiles.import_dangerfiles(except: %w[commit_messages])
80
+ # # Or import only a subset of rules, except a subset of rules
81
+ # dangerfiles.import_dangerfiles(only: %w[changes_size], except: %w[commit_messages])
82
+ # end
83
+ def import_dangerfiles(rules: nil, only: nil, except: [])
84
+ puts "The `:rules` parameter is deprecated in favor of `:only`." unless rules.nil?
85
+
86
+ only ||= EXISTING_RULES if rules == :all
87
+ only ||= rules || EXISTING_RULES
88
+
89
+ filtered_rules(only, except).each do |rule|
60
90
  danger_plugin.import_dangerfile(path: File.join(RULES_DIR, rule))
61
91
  end
62
92
  end
63
93
 
94
+ # Proxy method to +helper_plugin.config+.
95
+ def config
96
+ helper_plugin.config
97
+ end
98
+
99
+ # Imports all default plugins and rules.
100
+ #
101
+ # @example
102
+ # # In your main Dangerfile:
103
+ # Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
104
+ # dangerfiles.import_defaults
105
+ # end
106
+ def import_defaults
107
+ import_plugins
108
+ import_dangerfiles
109
+ end
110
+
64
111
  private
65
112
 
66
113
  attr_reader :dangerfile
@@ -71,10 +118,8 @@ module Gitlab
71
118
  helper_plugin.ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
72
119
  end
73
120
 
74
- def filtered_rules(rules)
75
- rules = EXISTING_RULES if rules == :all
76
-
77
- Array(rules).map(&:to_s) & EXISTING_RULES & allowed_rules
121
+ def filtered_rules(only, except)
122
+ (Array(only).map(&:to_s) & EXISTING_RULES & allowed_rules) - except
78
123
  end
79
124
 
80
125
  def danger_plugin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-dangerfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-gitlab
@@ -132,10 +132,12 @@ files:
132
132
  - ".gitignore"
133
133
  - ".gitlab-ci.yml"
134
134
  - ".gitlab/CODEOWNERS"
135
+ - ".gitlab/changelog_config.yml"
135
136
  - ".gitlab/merge_request_templates/Release.md"
136
137
  - ".rspec"
137
138
  - ".yardopts"
138
139
  - CODE_OF_CONDUCT.md
140
+ - CONTRIBUTING.md
139
141
  - Dangerfile
140
142
  - Gemfile
141
143
  - Guardfile
@@ -151,6 +153,7 @@ files:
151
153
  - lib/danger/plugins/roulette.rb
152
154
  - lib/danger/rules/changes_size/Dangerfile
153
155
  - lib/danger/rules/commit_messages/Dangerfile
156
+ - lib/danger/rules/simple_roulette/Dangerfile
154
157
  - lib/gitlab-dangerfiles.rb
155
158
  - lib/gitlab/Dangerfile
156
159
  - lib/gitlab/dangerfiles.rb