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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
847ada36
Commit
847ada36
authored
Nov 23, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Timeout creating and viewing merge request for binary file
parent
4646d453
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
changelogs/unreleased/timeout-merge-request-for-binary-file.yml
...logs/unreleased/timeout-merge-request-for-binary-file.yml
+4
-0
lib/gitlab/diff/file_collection/merge_request_diff.rb
lib/gitlab/diff/file_collection/merge_request_diff.rb
+3
-3
spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
...ib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+13
-0
spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
...s/merge_requests/merge_request_diff_cache_service_spec.rb
+1
-0
No files found.
changelogs/unreleased/timeout-merge-request-for-binary-file.yml
0 → 100644
View file @
847ada36
---
title
:
Timeout creating and viewing merge request for binary file
merge_request
:
author
:
lib/gitlab/diff/file_collection/merge_request_diff.rb
View file @
847ada36
...
@@ -20,7 +20,7 @@ module Gitlab
...
@@ -20,7 +20,7 @@ module Gitlab
# Extracted method to highlight in the same iteration to the diff_collection.
# Extracted method to highlight in the same iteration to the diff_collection.
def
decorate_diff!
(
diff
)
def
decorate_diff!
(
diff
)
diff_file
=
super
diff_file
=
super
cache_highlight!
(
diff_file
)
if
cacheable?
cache_highlight!
(
diff_file
)
if
cacheable?
(
diff_file
)
diff_file
diff_file
end
end
...
@@ -60,8 +60,8 @@ module Gitlab
...
@@ -60,8 +60,8 @@ module Gitlab
Rails
.
cache
.
write
(
cache_key
,
highlight_cache
)
if
@highlight_cache_was_empty
Rails
.
cache
.
write
(
cache_key
,
highlight_cache
)
if
@highlight_cache_was_empty
end
end
def
cacheable?
def
cacheable?
(
diff_file
)
@merge_request_diff
.
present?
@merge_request_diff
.
present?
&&
diff_file
.
blob
.
text?
end
end
def
cache_key
def
cache_key
...
...
spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
0 → 100644
View file @
847ada36
require
'spec_helper'
describe
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiff
do
let
(
:merge_request
)
{
create
:merge_request
}
it
'does not hightlight binary files'
do
allow_any_instance_of
(
Gitlab
::
Diff
::
File
).
to
receive
(
:blob
).
and_return
(
double
(
"text?"
=>
false
))
expect_any_instance_of
(
Gitlab
::
Diff
::
File
).
not_to
receive
(
:highlighted_diff_lines
)
described_class
.
new
(
merge_request
.
merge_request_diff
,
diff_options:
nil
).
diff_files
end
end
spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
View file @
847ada36
...
@@ -10,6 +10,7 @@ describe MergeRequests::MergeRequestDiffCacheService do
...
@@ -10,6 +10,7 @@ describe MergeRequests::MergeRequestDiffCacheService do
expect
(
Rails
.
cache
).
to
receive
(
:read
).
with
(
cache_key
).
and_return
({})
expect
(
Rails
.
cache
).
to
receive
(
:read
).
with
(
cache_key
).
and_return
({})
expect
(
Rails
.
cache
).
to
receive
(
:write
).
with
(
cache_key
,
anything
)
expect
(
Rails
.
cache
).
to
receive
(
:write
).
with
(
cache_key
,
anything
)
allow_any_instance_of
(
Gitlab
::
Diff
::
File
).
to
receive
(
:blob
).
and_return
(
double
(
"text?"
=>
true
))
subject
.
execute
(
merge_request
)
subject
.
execute
(
merge_request
)
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