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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
9ad59ae4
Commit
9ad59ae4
authored
Oct 29, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent Danger from showing both an error and a warning in some cases
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8b043949
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
danger/commit_messages/Dangerfile
danger/commit_messages/Dangerfile
+8
-6
No files found.
danger/commit_messages/Dangerfile
View file @
9ad59ae4
...
...
@@ -101,25 +101,27 @@ end
def
lint_commits
(
commits
)
commit_linters
=
commits
.
map
{
|
commit
|
lint_commit
(
commit
)
}
failed_commit_linters
=
commit_linters
.
select
{
|
commit_linter
|
commit_linter
.
failed?
}
warn_or_fail_commits
(
failed_commit_linters
,
default_to_fail:
!
squash_mr?
)
if
count_non_fixup_commits
(
commit_linters
)
>
MAX_COMMITS_COUNT
self
.
warn
(
format
(
MAX_COMMITS_COUNT_EXCEEDED_MESSAGE
,
max_commits_count:
MAX_COMMITS_COUNT
))
end
if
squash_mr?
multi_line_commit_linter
=
commit_linters
.
detect
{
|
commit_linter
|
!
commit_linter
.
merge?
&&
commit_linter
.
multi_line?
}
if
multi_line_commit_linter
&&
multi_line_commit_linter
.
failed?
warn_or_fail_commits
(
multi_line_commit_linter
)
commit_linters
.
delete
(
multi_line_commit_linter
)
# Don't show an error (here) and a warning (below)
elsif
gitlab_danger
.
ci?
# We don't have access to the MR title locally
title_linter
=
lint_mr_title
(
gitlab
.
mr_json
[
'title'
])
if
title_linter
.
failed?
warn_or_fail_commits
(
title_linter
)
end
end
else
if
count_non_fixup_commits
(
commit_linters
)
>
MAX_COMMITS_COUNT
self
.
warn
(
format
(
MAX_COMMITS_COUNT_EXCEEDED_MESSAGE
,
max_commits_count:
MAX_COMMITS_COUNT
))
end
end
failed_commit_linters
=
commit_linters
.
select
{
|
commit_linter
|
commit_linter
.
failed?
}
warn_or_fail_commits
(
failed_commit_linters
,
default_to_fail:
!
squash_mr?
)
end
def
warn_or_fail_commits
(
failed_linters
,
default_to_fail:
true
)
...
...
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