Commit 988c1753 authored by nmilojevic1's avatar nmilojevic1

FIx diff file creation

- In case when DiffFile is not found
- In case when DiffLine is not found
parent 1578bae2
...@@ -37,7 +37,8 @@ class DiffNote < Note ...@@ -37,7 +37,8 @@ class DiffNote < Note
creation_params = diff_file.diff.to_hash creation_params = diff_file.diff.to_hash
.except(:too_large) .except(:too_large)
.merge(diff: diff_file.diff_hunk(diff_line))
creation_params.merge(diff: diff_file.diff_hunk(diff_line)) if diff_line
create_note_diff_file(creation_params) create_note_diff_file(creation_params)
end end
...@@ -109,19 +110,16 @@ class DiffNote < Note ...@@ -109,19 +110,16 @@ class DiffNote < Note
def fetch_diff_file def fetch_diff_file
return note_diff_file.raw_diff_file if note_diff_file return note_diff_file.raw_diff_file if note_diff_file
if created_at_diff?(noteable.diff_refs)
file = # We're able to use the already persisted diffs (Postgres) if we're
if created_at_diff?(noteable.diff_refs) # presenting a "current version" of the MR discussion diff.
# We're able to use the already persisted diffs (Postgres) if we're # So no need to make an extra Gitaly diff request for it.
# presenting a "current version" of the MR discussion diff. # As an extra benefit, the returned `diff_file` already
# So no need to make an extra Gitaly diff request for it. # has `highlighted_diff_lines` data set from Redis on
# As an extra benefit, the returned `diff_file` already # `Diff::FileCollection::MergeRequestDiff`.
# has `highlighted_diff_lines` data set from Redis on file = noteable.diffs(original_position.diff_options).diff_files.first
# `Diff::FileCollection::MergeRequestDiff`. end
noteable.diffs(original_position.diff_options).diff_files.first file ||= original_position.diff_file(repository)
else
original_position.diff_file(repository)
end
file&.unfold_diff_lines(position) file&.unfold_diff_lines(position)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment