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
22ca5634
Commit
22ca5634
authored
Dec 12, 2019
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose unhighlighted diff_files
parent
f39b4463
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
19 deletions
+16
-19
lib/gitlab/diff/file_collection/base.rb
lib/gitlab/diff/file_collection/base.rb
+5
-1
lib/gitlab/diff/file_collection/merge_request_diff_base.rb
lib/gitlab/diff/file_collection/merge_request_diff_base.rb
+5
-7
lib/gitlab/diff/highlight_cache.rb
lib/gitlab/diff/highlight_cache.rb
+4
-1
spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
...ib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+0
-8
spec/lib/gitlab/diff/highlight_cache_spec.rb
spec/lib/gitlab/diff/highlight_cache_spec.rb
+2
-2
No files found.
lib/gitlab/diff/file_collection/base.rb
View file @
22ca5634
...
...
@@ -31,7 +31,11 @@ module Gitlab
end
def
diff_files
@diff_files
||=
diffs
.
decorate!
{
|
diff
|
decorate_diff!
(
diff
)
}
raw_diff_files
end
def
raw_diff_files
@raw_diff_files
||=
diffs
.
decorate!
{
|
diff
|
decorate_diff!
(
diff
)
}
end
def
diff_file_paths
...
...
lib/gitlab/diff/file_collection/merge_request_diff_base.rb
View file @
22ca5634
...
...
@@ -16,15 +16,13 @@ module Gitlab
fallback_diff_refs:
merge_request_diff
.
fallback_diff_refs
)
end
def
diff_files
(
decorate_diff_files:
true
)
files
=
super
()
def
diff_files
strong_memoize
(
:diff_files
)
do
diff_files
=
super
return
files
unless
decorate_diff_files
diff_files
.
each
{
|
diff_file
|
cache
.
decorate
(
diff_file
)
}
strong_memoize
(
:decorated_diff_files
)
do
files
.
each
{
|
diff_file
|
cache
.
decorate
(
diff_file
)
}
files
diff_files
end
end
...
...
lib/gitlab/diff/highlight_cache.rb
View file @
22ca5634
...
...
@@ -145,7 +145,10 @@ module Gitlab
end
def
diff_files
@diff_collection
.
diff_files
(
decorate_diff_files:
false
)
# We access the raw, undecorated diff_files here, as decorating refers
# back into this class and leads to a circular reference.
#
@diff_collection
.
raw_diff_files
end
end
end
...
...
spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
View file @
22ca5634
...
...
@@ -9,14 +9,6 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
let
(
:diff_files
)
{
subject
.
diff_files
}
describe
'#diff_files'
do
context
'when decorate_diff_files is false'
do
it
'does not attempt to decorate diff files'
do
expect_any_instance_of
(
Gitlab
::
Diff
::
HighlightCache
).
not_to
receive
(
:decorate
)
subject
.
diff_files
(
decorate_diff_files:
false
)
end
end
it
'does not highlight binary files'
do
allow_next_instance_of
(
Gitlab
::
Diff
::
File
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:text?
).
and_return
(
false
)
...
...
spec/lib/gitlab/diff/highlight_cache_spec.rb
View file @
22ca5634
...
...
@@ -98,7 +98,7 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
describe
'#write_if_empty'
do
it_behaves_like
'caches missing entries'
do
let
(
:paths
)
{
merge_request
.
diffs
.
diff_files
.
select
(
&
:text?
).
map
(
&
:file_path
)
}
let
(
:paths
)
{
merge_request
.
diffs
.
raw_
diff_files
.
select
(
&
:text?
).
map
(
&
:file_path
)
}
end
context
'different diff_collections for the same diffable'
do
...
...
@@ -125,7 +125,7 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
it_behaves_like
'caches missing entries'
do
let
(
:cache
)
{
described_class
.
new
(
merge_request_diff_batch
)
}
let
(
:paths
)
{
merge_request_diff_batch
.
diff_files
.
select
(
&
:text?
).
map
(
&
:file_path
)
}
let
(
:paths
)
{
merge_request_diff_batch
.
raw_
diff_files
.
select
(
&
:text?
).
map
(
&
:file_path
)
}
end
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