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
61875426
Commit
61875426
authored
May 12, 2021
by
Gary Holtz
Committed by
Mark Chao
May 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding initial tracking for file size highlight limits
parent
db8dc95f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
+39
-5
config/feature_flags/development/track_file_size_over_highlight_limit.yml
...lags/development/track_file_size_over_highlight_limit.yml
+8
-0
lib/gitlab/highlight.rb
lib/gitlab/highlight.rb
+12
-1
spec/lib/gitlab/highlight_spec.rb
spec/lib/gitlab/highlight_spec.rb
+19
-4
No files found.
config/feature_flags/development/track_file_size_over_highlight_limit.yml
0 → 100644
View file @
61875426
---
name
:
track_file_size_over_highlight_limit
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61273
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/330374
milestone
:
'
13.12'
type
:
development
group
:
group::code review
default_enabled
:
false
lib/gitlab/highlight.rb
View file @
61875426
...
...
@@ -11,7 +11,11 @@ module Gitlab
end
def
self
.
too_large?
(
size
)
size
.
to_i
>
Gitlab
.
config
.
extra
[
'maximum_text_highlight_size_kilobytes'
]
return
false
unless
size
.
to_i
>
Gitlab
.
config
.
extra
[
'maximum_text_highlight_size_kilobytes'
]
over_highlight_size_limit
.
increment
(
source:
"text highlighter"
)
if
Feature
.
enabled?
(
:track_file_size_over_highlight_limit
)
true
end
attr_reader
:blob_name
...
...
@@ -96,5 +100,12 @@ module Gitlab
'Counts the times highlights have timed out'
)
end
def
self
.
over_highlight_size_limit
@over_highlight_size_limit
||=
Gitlab
::
Metrics
.
counter
(
:over_highlight_size_limit
,
'Count the times files have been over the highlight size limit'
)
end
end
end
spec/lib/gitlab/highlight_spec.rb
View file @
61875426
...
...
@@ -46,12 +46,20 @@ RSpec.describe Gitlab::Highlight do
expect
(
result
).
to
eq
(
%[<span id="LC1" class="line" lang="plaintext">plain text contents</span>]
)
end
it
'returns plain version for long content
'
do
stub_config
(
extra:
{
'maximum_text_highlight_size_kilobytes'
=>
0.0001
}
)
# 1.02
4 bytes
context
'when content is too long to be highlighted
'
do
let
(
:result
)
{
described_class
.
highlight
(
file_name
,
content
)
}
# content is 4
4 bytes
result
=
described_class
.
highlight
(
file_name
,
content
)
# content is 44 bytes
before
do
stub_config
(
extra:
{
'maximum_text_highlight_size_kilobytes'
=>
0.0001
}
)
# 1.024 bytes
end
it
'increments the metric for oversized files'
do
expect
{
result
}.
to
change
{
over_highlight_size_limit
(
'text highlighter'
)
}.
by
(
1
)
end
expect
(
result
).
to
eq
(
%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem")</span>]
)
it
'returns plain version for long content'
do
expect
(
result
).
to
eq
(
%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem")</span>]
)
end
end
it
'highlights multi-line comments'
do
...
...
@@ -168,4 +176,11 @@ RSpec.describe Gitlab::Highlight do
.
counter
(
:highlight_timeout
,
'Counts the times highlights have timed out'
)
.
get
(
source:
source
)
end
def
over_highlight_size_limit
(
source
)
Gitlab
::
Metrics
.
counter
(
:over_highlight_size_limit
,
'Count the times text has been over the highlight size limit'
)
.
get
(
source:
source
)
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