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
66bc7de8
Commit
66bc7de8
authored
Dec 16, 2019
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make use of uncached diffs where highlighting is not required
parent
222e7033
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
8 deletions
+16
-8
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+1
-1
app/serializers/diffs_entity.rb
app/serializers/diffs_entity.rb
+2
-2
app/serializers/diffs_metadata_entity.rb
app/serializers/diffs_metadata_entity.rb
+1
-1
lib/gitlab/diff/file_collection/base.rb
lib/gitlab/diff/file_collection/base.rb
+1
-1
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+1
-1
spec/serializers/diffs_metadata_entity_spec.rb
spec/serializers/diffs_metadata_entity_spec.rb
+10
-2
No files found.
app/helpers/diff_helper.rb
View file @
66bc7de8
...
...
@@ -162,7 +162,7 @@ module DiffHelper
end
def
render_overflow_warning?
(
diffs_collection
)
diff_files
=
diffs_collection
.
diff_files
diff_files
=
diffs_collection
.
raw_
diff_files
if
diff_files
.
any?
(
&
:too_large?
)
Gitlab
::
Metrics
.
add_event
(
:diffs_overflow_single_file_limits
)
...
...
app/serializers/diffs_entity.rb
View file @
66bc7de8
...
...
@@ -42,13 +42,13 @@ class DiffsEntity < Grape::Entity
# rubocop: disable CodeReuse/ActiveRecord
expose
:added_lines
do
|
diffs
|
diffs
.
diff_files
.
sum
(
&
:added_lines
)
diffs
.
raw_
diff_files
.
sum
(
&
:added_lines
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
expose
:removed_lines
do
|
diffs
|
diffs
.
diff_files
.
sum
(
&
:removed_lines
)
diffs
.
raw_
diff_files
.
sum
(
&
:removed_lines
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/serializers/diffs_metadata_entity.rb
View file @
66bc7de8
...
...
@@ -2,5 +2,5 @@
class
DiffsMetadataEntity
<
DiffsEntity
unexpose
:diff_files
expose
:diff_files
,
using:
DiffFileMetadataEntity
expose
:
raw_diff_files
,
as: :
diff_files
,
using:
DiffFileMetadataEntity
end
lib/gitlab/diff/file_collection/base.rb
View file @
66bc7de8
...
...
@@ -8,7 +8,7 @@ module Gitlab
attr_reader
:project
,
:diff_options
,
:diff_refs
,
:fallback_diff_refs
,
:diffable
delegate
:count
,
:size
,
:real_size
,
to: :diff_files
delegate
:count
,
:size
,
:real_size
,
to: :
raw_
diff_files
def
self
.
default_options
::
Commit
.
max_diff_options
.
merge
(
ignore_whitespace_change:
false
,
expanded:
false
,
include_stats:
true
)
...
...
spec/helpers/diff_helper_spec.rb
View file @
66bc7de8
...
...
@@ -259,7 +259,7 @@ describe DiffHelper do
end
context
'#render_overflow_warning?'
do
let
(
:diffs_collection
)
{
instance_double
(
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiff
,
diff_files:
diff_files
)
}
let
(
:diffs_collection
)
{
instance_double
(
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiff
,
raw_
diff_files:
diff_files
)
}
let
(
:diff_files
)
{
Gitlab
::
Git
::
DiffCollection
.
new
(
files
)
}
let
(
:safe_file
)
{
{
too_large:
false
,
diff:
''
}
}
let
(
:large_file
)
{
{
too_large:
true
,
diff:
''
}
}
...
...
spec/serializers/diffs_metadata_entity_spec.rb
View file @
66bc7de8
...
...
@@ -36,8 +36,16 @@ describe DiffsMetadataEntity do
describe
'diff_files'
do
it
'returns diff files metadata'
do
payload
=
DiffFileMetadataEntity
.
represent
(
merge_request_diff
.
diffs
.
diff_files
).
as_json
raw_diff_files
=
merge_request_diff
.
diffs
.
raw_diff_files
expect_next_instance_of
(
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiff
)
do
|
instance
|
# Use lightweight version instead. Several methods delegate to it, so putting a 5
# calls limit.
expect
(
instance
).
to
receive
(
:raw_diff_files
).
at_most
(
5
).
times
.
and_call_original
expect
(
instance
).
not_to
receive
(
:diff_files
)
end
payload
=
DiffFileMetadataEntity
.
represent
(
raw_diff_files
).
as_json
expect
(
subject
[
:diff_files
]).
to
eq
(
payload
)
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