Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
f034a352
Commit
f034a352
authored
Feb 07, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move change category detection to a helper
parent
bd17881b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
danger/documentation/Dangerfile
danger/documentation/Dangerfile
+1
-12
danger/plugins/helper.rb
danger/plugins/helper.rb
+17
-0
No files found.
danger/documentation/Dangerfile
View file @
f034a352
# frozen_string_literal: true
# All the files/directories that should be reviewed by the Docs team.
DOCS_FILES
=
[
'doc/'
].
freeze
def
docs_paths_requiring_review
(
files
)
files
.
select
do
|
file
|
DOCS_FILES
.
any?
{
|
pattern
|
file
.
start_with?
(
pattern
)
}
end
end
docs_paths_to_review
=
docs_paths_requiring_review
(
helper
.
all_changed_files
)
docs_paths_to_review
=
helper
.
changes_by_category
[
:documentation
]
unless
docs_paths_to_review
.
empty?
message
'This merge request adds or changes files that require a '
\
...
...
danger/plugins/helper.rb
View file @
f034a352
...
...
@@ -30,5 +30,22 @@ module Danger
.
to_a
.
sort
end
# @return [Hash<String,Array<String>>]
def
changes_by_category
all_changed_files
.
inject
(
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
})
do
|
hsh
,
file
|
hsh
[
category_for_file
(
file
)]
<<
file
end
end
def
category_for_file
(
file
)
_
,
category
=
CATEGORIES
.
find
{
|
regexp
,
_
|
regexp
.
match?
(
file
)
}
category
||
:unknown
end
CATEGORIES
=
{
%r{
\A
doc/}
=>
:documentation
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment