Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
aa8846e66125
Commit
5a3237fd
authored
Dec 20, 2015
by
Jared Szechy
Browse files
Fix build coverage regex.
Added a spec for regex captures as well. Fixes #2644
parent
42299c3290e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/ci/build.rb
View file @
aa8846e6
...
...
@@ -170,7 +170,8 @@ def update_coverage
def
extract_coverage
(
text
,
regex
)
begin
matches
=
regex
.
match
(
text
).
to_a
.
last
matches
=
text
.
scan
(
Regexp
.
new
(
regex
)).
last
matches
=
matches
.
last
if
matches
.
kind_of?
(
Array
)
coverage
=
matches
.
gsub
(
/\d+(\.\d+)?/
).
first
if
coverage
.
present?
...
...
spec/models/build_spec.rb
View file @
aa8846e6
...
...
@@ -189,6 +189,12 @@
it
{
is_expected
.
to
eq
(
98.29
)
}
end
context
'using a regex capture'
do
subject
{
build
.
extract_coverage
(
'TOTAL 9926 3489 65%'
,
'TOTAL\s+\d+\s+\d+\s+(\d{1,3}\%)'
)
}
it
{
is_expected
.
to
eq
(
65
)
}
end
end
describe
:variables
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