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
19ebb829
Commit
19ebb829
authored
Dec 01, 2020
by
Doug Stull
Committed by
Rémy Coutable
Dec 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add danger missing test coverage
- for 100% coverage
parent
a44bf93d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
17 deletions
+18
-17
lib/gitlab/danger/commit_linter.rb
lib/gitlab/danger/commit_linter.rb
+3
-14
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+1
-1
spec/lib/gitlab/danger/commit_linter_spec.rb
spec/lib/gitlab/danger/commit_linter_spec.rb
+4
-2
spec/lib/gitlab/danger/helper_spec.rb
spec/lib/gitlab/danger/helper_spec.rb
+10
-0
No files found.
lib/gitlab/danger/commit_linter.rb
View file @
19ebb829
...
...
@@ -114,15 +114,11 @@ module Gitlab
end
details
&
.
each_line
do
|
line
|
line
=
line
.
strip
next
unless
line_too_long?
(
line
)
url_size
=
line
.
scan
(
%r((https?://
\S
+))
).
sum
{
|
(
url
)
|
url
.
length
}
line_without_urls
=
line
.
strip
.
gsub
(
%r{https?://
\S
+}
,
''
)
# If the line includes a URL, we'll allow it to exceed MAX_LINE_LENGTH characters, but
# only if the line _without_ the URL does not exceed this limit.
next
unless
line_too_long?
(
line
.
length
-
url_size
)
next
unless
line_too_long?
(
line
_without_urls
)
add_problem
(
:details_line_too_long
)
break
...
...
@@ -172,14 +168,7 @@ module Gitlab
end
def
line_too_long?
(
line
)
case
line
when
String
line
.
length
>
MAX_LINE_LENGTH
when
Integer
line
>
MAX_LINE_LENGTH
else
raise
ArgumentError
,
"The line argument (
#{
line
}
) should be a String or an Integer!
#{
line
.
class
}
given."
end
end
def
subject_too_short?
...
...
lib/gitlab/danger/helper.rb
View file @
19ebb829
...
...
@@ -64,7 +64,7 @@ module Gitlab
# - respond_to?(:gitlab)
# - respond_to?(:gitlab, true)
gitlab
rescue
N
oMethod
Error
rescue
N
ame
Error
nil
end
...
...
spec/lib/gitlab/danger/commit_linter_spec.rb
View file @
19ebb829
...
...
@@ -300,8 +300,10 @@ RSpec.describe Gitlab::Danger::CommitLinter do
end
end
context
'when details exceeds the max line length including a URL'
do
let
(
:commit_message
)
{
"A B C
\n\n
https://gitlab.com"
+
'D'
*
described_class
::
MAX_LINE_LENGTH
}
context
'when details exceeds the max line length including URLs'
do
let
(
:commit_message
)
do
"A B C
\n\n
some message with https://example.com and https://gitlab.com"
+
'D'
*
described_class
::
MAX_LINE_LENGTH
end
it_behaves_like
'a valid commit'
end
...
...
spec/lib/gitlab/danger/helper_spec.rb
View file @
19ebb829
...
...
@@ -33,6 +33,16 @@ RSpec.describe Gitlab::Danger::Helper do
expect
(
helper
.
gitlab_helper
).
to
eq
(
fake_gitlab
)
end
end
context
'when danger gitlab plugin is not available'
do
it
'returns nil'
do
invalid_danger
=
Class
.
new
do
include
Gitlab
::
Danger
::
Helper
end
.
new
expect
(
invalid_danger
.
gitlab_helper
).
to
be_nil
end
end
end
describe
'#release_automation?'
do
...
...
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