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
6d41df50
Commit
6d41df50
authored
Jul 04, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render LegacyDiffNote when diff_file blob is nil
parent
d66bbf82
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
app/serializers/diff_file_entity.rb
app/serializers/diff_file_entity.rb
+5
-0
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+1
-0
spec/serializers/diff_file_entity_spec.rb
spec/serializers/diff_file_entity_spec.rb
+14
-0
No files found.
app/serializers/diff_file_entity.rb
View file @
6d41df50
...
...
@@ -25,6 +25,8 @@ class DiffFileEntity < Grape::Entity
expose
:can_modify_blob
do
|
diff_file
|
merge_request
=
options
[
:merge_request
]
next
unless
diff_file
.
blob
if
merge_request
&
.
source_project
&&
current_user
can_modify_blob?
(
diff_file
.
blob
,
merge_request
.
source_project
,
merge_request
.
source_branch
)
else
...
...
@@ -108,6 +110,7 @@ class DiffFileEntity < Grape::Entity
project
=
merge_request
.
target_project
next
unless
project
next
unless
diff_file
.
content_sha
project_blob_path
(
project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
new_path
))
end
...
...
@@ -125,6 +128,8 @@ class DiffFileEntity < Grape::Entity
end
expose
:context_lines_path
,
if:
->
(
diff_file
,
_
)
{
diff_file
.
text?
}
do
|
diff_file
|
next
unless
diff_file
.
content_sha
project_blob_diff_path
(
diff_file
.
repository
.
project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
file_path
))
end
...
...
lib/gitlab/diff/file.rb
View file @
6d41df50
...
...
@@ -247,6 +247,7 @@ module Gitlab
lines
=
highlighted_diff_lines
return
if
lines
.
empty?
return
if
blob
.
nil?
last_line
=
lines
.
last
...
...
spec/serializers/diff_file_entity_spec.rb
View file @
6d41df50
...
...
@@ -25,6 +25,20 @@ describe DiffFileEntity do
:context_lines_path
)
end
# Converted diff files from GitHub import does not contain blob file
# and content sha.
context
'when diff file does not have a blob and content sha'
do
it
'exposes some attributes as nil'
do
allow
(
diff_file
).
to
receive
(
:content_sha
).
and_return
(
nil
)
allow
(
diff_file
).
to
receive
(
:blob
).
and_return
(
nil
)
expect
(
subject
[
:context_lines_path
]).
to
be_nil
expect
(
subject
[
:view_path
]).
to
be_nil
expect
(
subject
[
:highlighted_diff_lines
]).
to
be_nil
expect
(
subject
[
:can_modify_blob
]).
to
be_nil
end
end
end
context
'when there is no merge request'
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