summaryrefslogtreecommitdiff
path: root/app/models/diff_note.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:14:39 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:14:39 +0000
commit1eb82b65c554f21d83447f895a6208905fabe112 (patch)
treeab12f01b3dc46f11c02afea1e470a78f06ca70c2 /app/models/diff_note.rb
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
downloadgitlab-ce-stable-branch-foss-test.tar.gz
Add latest changes from gitlab-org/gitlab@12-3-auto-deploy-20190916stable-branch-foss-test
Diffstat (limited to 'app/models/diff_note.rb')
-rw-r--r--app/models/diff_note.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index aa7286a9971..0b00cf10714 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -108,10 +108,13 @@ class DiffNote < Note
end
def fetch_diff_file
- return note_diff_file.raw_diff_file if note_diff_file
-
file =
- if created_at_diff?(noteable.diff_refs)
+ if note_diff_file
+ diff = Gitlab::Git::Diff.new(note_diff_file.to_hash)
+ Gitlab::Diff::File.new(diff,
+ repository: repository,
+ diff_refs: original_position.diff_refs)
+ elsif created_at_diff?(noteable.diff_refs)
# We're able to use the already persisted diffs (Postgres) if we're
# presenting a "current version" of the MR discussion diff.
# So no need to make an extra Gitaly diff request for it.
@@ -123,7 +126,9 @@ class DiffNote < Note
original_position.diff_file(repository)
end
- file&.unfold_diff_lines(position)
+ # Since persisted diff files already have its content "unfolded"
+ # there's no need to make it pass through the unfolding process.
+ file&.unfold_diff_lines(position) unless note_diff_file
file
end