gitlab-dangerfiles 1.1.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +36 -1
- data/.yardopts +5 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +57 -6
- data/gitlab-dangerfiles.gemspec +3 -3
- data/lib/danger/plugins/helper.rb +190 -88
- data/lib/danger/plugins/roulette.rb +75 -43
- data/lib/danger/rules/changes_size/Dangerfile +10 -0
- data/lib/danger/rules/commit_messages/Dangerfile +138 -0
- data/lib/gitlab/dangerfiles.rb +82 -2
- data/lib/gitlab/dangerfiles/changes.rb +22 -0
- data/lib/gitlab/dangerfiles/commit_linter.rb +7 -3
- data/lib/gitlab/dangerfiles/config.rb +23 -0
- data/lib/gitlab/dangerfiles/emoji_checker.rb +1 -0
- data/lib/gitlab/dangerfiles/teammate.rb +0 -5
- data/lib/gitlab/dangerfiles/title_linting.rb +2 -0
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- data/lib/gitlab/dangerfiles/weightage.rb +1 -0
- data/lib/gitlab/dangerfiles/weightage/maintainers.rb +1 -0
- data/lib/gitlab/dangerfiles/weightage/reviewers.rb +1 -0
- metadata +10 -6
@@ -8,14 +8,17 @@ module Gitlab
|
|
8
8
|
class CommitLinter < BaseLinter
|
9
9
|
MAX_CHANGED_FILES_IN_COMMIT = 3
|
10
10
|
MAX_CHANGED_LINES_IN_COMMIT = 30
|
11
|
-
|
11
|
+
# Issue, MR, Epic
|
12
|
+
SHORT_REFERENCE_REGEX = %r{([\w\-\/]+)?(?<!`)(#|!|&)\d+(?<!`)}.freeze
|
13
|
+
# Milestone
|
14
|
+
MS_SHORT_REFERENCE_REGEX = %r{([\w\-\/]+)?(?<!`)%"?\d{1,3}\.\d{1,3}"?(?<!`)}.freeze
|
12
15
|
|
13
16
|
def self.problems_mapping
|
14
17
|
super.merge(
|
15
18
|
{
|
16
19
|
separator_missing: "The commit subject and body must be separated by a blank line",
|
17
20
|
details_too_many_changes: "Commits that change #{MAX_CHANGED_LINES_IN_COMMIT} or more lines across " \
|
18
|
-
"at least #{MAX_CHANGED_FILES_IN_COMMIT} files
|
21
|
+
"at least #{MAX_CHANGED_FILES_IN_COMMIT} files should describe these changes in the commit body",
|
19
22
|
details_line_too_long: "The commit body should not contain more than #{MAX_LINE_LENGTH} characters per line",
|
20
23
|
message_contains_text_emoji: "Avoid the use of Markdown Emoji such as `:+1:`. These add limited value " \
|
21
24
|
"to the commit message, and are displayed as plain text outside of GitLab",
|
@@ -139,7 +142,8 @@ module Gitlab
|
|
139
142
|
end
|
140
143
|
|
141
144
|
def message_contains_short_reference?
|
142
|
-
commit.message.match?(SHORT_REFERENCE_REGEX)
|
145
|
+
commit.message.match?(SHORT_REFERENCE_REGEX) ||
|
146
|
+
commit.message.match?(MS_SHORT_REFERENCE_REGEX)
|
143
147
|
end
|
144
148
|
|
145
149
|
def emoji_checker
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Dangerfiles
|
5
|
+
class Config
|
6
|
+
# @!attribute code_size_thresholds
|
7
|
+
# @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
|
+
attr_accessor :code_size_thresholds
|
9
|
+
|
10
|
+
# @!attribute max_commits_count
|
11
|
+
# @return [Integer] the maximum number of allowed non-squashed/non-fixup commits for a given MR. A warning is triggered if the MR has more commits.
|
12
|
+
attr_accessor :max_commits_count
|
13
|
+
|
14
|
+
DEFAULT_CHANGES_SIZE_THRESHOLDS = { high: 2_000, medium: 500 }.freeze
|
15
|
+
DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT = 10
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@code_size_thresholds = DEFAULT_CHANGES_SIZE_THRESHOLDS
|
19
|
+
@max_commits_count = DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -101,11 +101,6 @@ module Gitlab
|
|
101
101
|
return true if capabilities(project).include?("#{kind} engineering_productivity")
|
102
102
|
|
103
103
|
capabilities(project).include?("#{kind} backend")
|
104
|
-
when :product_intelligence
|
105
|
-
return false unless role[/Engineer, Product Intelligence/]
|
106
|
-
|
107
|
-
# any reviewer of project from Product Intelligence team can review MR
|
108
|
-
kind == :reviewer && capabilities(project).any?
|
109
104
|
when nil
|
110
105
|
capabilities(project).include?("#{kind}")
|
111
106
|
else
|
@@ -18,6 +18,7 @@ module Gitlab
|
|
18
18
|
# | hungry traintainer | 8 |
|
19
19
|
# +------------------------------+--------------------------------+
|
20
20
|
#
|
21
|
+
# @api private
|
21
22
|
class Reviewers
|
22
23
|
DEFAULT_REVIEWER_WEIGHT = Gitlab::Dangerfiles::Weightage::CAPACITY_MULTIPLIER * Gitlab::Dangerfiles::Weightage::BASE_REVIEWER_WEIGHT
|
23
24
|
TRAINTAINER_WEIGHT = 3
|
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:
|
4
|
+
version: 2.1.3
|
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
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-gitlab
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
description: This gem provides common Dangerfile and plugins for GitLab projects.
|
112
112
|
email:
|
113
|
-
-
|
113
|
+
- gitlab_rubygems@gitlab.com
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".gitlab-ci.yml"
|
120
120
|
- ".gitlab/merge_request_templates/Release.md"
|
121
121
|
- ".rspec"
|
122
|
+
- ".yardopts"
|
122
123
|
- CODE_OF_CONDUCT.md
|
123
124
|
- Gemfile
|
124
125
|
- Guardfile
|
@@ -132,12 +133,15 @@ files:
|
|
132
133
|
- gitlab-dangerfiles.gemspec
|
133
134
|
- lib/danger/plugins/helper.rb
|
134
135
|
- lib/danger/plugins/roulette.rb
|
136
|
+
- lib/danger/rules/changes_size/Dangerfile
|
137
|
+
- lib/danger/rules/commit_messages/Dangerfile
|
135
138
|
- lib/gitlab-dangerfiles.rb
|
136
139
|
- lib/gitlab/Dangerfile
|
137
140
|
- lib/gitlab/dangerfiles.rb
|
138
141
|
- lib/gitlab/dangerfiles/base_linter.rb
|
139
142
|
- lib/gitlab/dangerfiles/changes.rb
|
140
143
|
- lib/gitlab/dangerfiles/commit_linter.rb
|
144
|
+
- lib/gitlab/dangerfiles/config.rb
|
141
145
|
- lib/gitlab/dangerfiles/emoji_checker.rb
|
142
146
|
- lib/gitlab/dangerfiles/merge_request_linter.rb
|
143
147
|
- lib/gitlab/dangerfiles/spec_helper.rb
|
@@ -154,7 +158,7 @@ metadata:
|
|
154
158
|
allowed_push_host: https://rubygems.org
|
155
159
|
homepage_uri: https://gitlab.com/gitlab-org/gitlab-dangerfiles
|
156
160
|
source_code_uri: https://gitlab.com/gitlab-org/gitlab-dangerfiles
|
157
|
-
changelog_uri: https://gitlab.com/gitlab-org/gitlab-dangerfiles
|
161
|
+
changelog_uri: https://gitlab.com/gitlab-org/gitlab-dangerfiles/-/releases
|
158
162
|
post_install_message:
|
159
163
|
rdoc_options: []
|
160
164
|
require_paths:
|
@@ -170,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
174
|
- !ruby/object:Gem::Version
|
171
175
|
version: '0'
|
172
176
|
requirements: []
|
173
|
-
rubygems_version: 3.1.
|
177
|
+
rubygems_version: 3.1.6
|
174
178
|
signing_key:
|
175
179
|
specification_version: 4
|
176
180
|
summary: This gem provides common Dangerfile and plugins for GitLab projects.
|