@@ -66,10 +66,6 @@ def created_at_diff?(diff_refs)
6666 self . original_position . diff_refs == diff_refs
6767 end
6868
69- def discussion_first_note?
70- self == discussion . first_note
71- end
72-
7369 private
7470
7571 def enqueue_diff_file_creation_job
@@ -82,33 +78,26 @@ def enqueue_diff_file_creation_job
8278 end
8379
8480 def should_create_diff_file?
85- on_text? && note_diff_file . nil? && discussion_first_note?
81+ on_text? && note_diff_file . nil? && self == discussion . first_note
8682 end
8783
8884 def fetch_diff_file
89- file =
90- if note_diff_file
91- diff = Gitlab ::Git ::Diff . new ( note_diff_file . to_hash )
92- Gitlab ::Diff ::File . new ( diff ,
93- repository : project . repository ,
94- diff_refs : original_position . diff_refs )
95- elsif created_at_diff? ( noteable . diff_refs )
96- # We're able to use the already persisted diffs (Postgres) if we're
97- # presenting a "current version" of the MR discussion diff.
98- # So no need to make an extra Gitaly diff request for it.
99- # As an extra benefit, the returned `diff_file` already
100- # has `highlighted_diff_lines` data set from Redis on
101- # `Diff::FileCollection::MergeRequestDiff`.
102- noteable . diffs ( original_position . diff_options ) . diff_files . first
103- else
104- original_position . diff_file ( self . project . repository )
105- end
106-
107- # Since persisted diff files already have its content "unfolded"
108- # there's no need to make it pass through the unfolding process.
109- file &.unfold_diff_lines ( position ) unless note_diff_file
110-
111- file
85+ if note_diff_file
86+ diff = Gitlab ::Git ::Diff . new ( note_diff_file . to_hash )
87+ Gitlab ::Diff ::File . new ( diff ,
88+ repository : project . repository ,
89+ diff_refs : original_position . diff_refs )
90+ elsif created_at_diff? ( noteable . diff_refs )
91+ # We're able to use the already persisted diffs (Postgres) if we're
92+ # presenting a "current version" of the MR discussion diff.
93+ # So no need to make an extra Gitaly diff request for it.
94+ # As an extra benefit, the returned `diff_file` already
95+ # has `highlighted_diff_lines` data set from Redis on
96+ # `Diff::FileCollection::MergeRequestDiff`.
97+ noteable . diffs ( original_position . diff_options ) . diff_files . first
98+ else
99+ original_position . diff_file ( self . project . repository )
100+ end
112101 end
113102
114103 def supported?
0 commit comments