diff options
author | Nick Thomas <nick@gitlab.com> | 2019-01-09 20:01:28 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-02-05 17:12:48 +0300 |
commit | f9e41d0d851ae0ab1d67df63d0309fdce97517e1 (patch) | |
tree | 3c71a5853b789ff57d8a47522d8603c36eb7aa59 /app/models/merge_request_diff_file.rb | |
parent | f04910f254c29047dd3ae798161683a722e7162b (diff) |
Allow MR diffs to be placed into an object store
Diffstat (limited to 'app/models/merge_request_diff_file.rb')
-rw-r--r-- | app/models/merge_request_diff_file.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/merge_request_diff_file.rb b/app/models/merge_request_diff_file.rb index a9f110bec5c..e8d936e265c 100644 --- a/app/models/merge_request_diff_file.rb +++ b/app/models/merge_request_diff_file.rb @@ -4,7 +4,7 @@ class MergeRequestDiffFile < ActiveRecord::Base include Gitlab::EncodingHelper include DiffFile - belongs_to :merge_request_diff + belongs_to :merge_request_diff, inverse_of: :merge_request_diff_files def utf8_diff return '' if diff.blank? @@ -13,6 +13,16 @@ class MergeRequestDiffFile < ActiveRecord::Base end def diff - binary? ? super.unpack('m0').first : super + content = + if merge_request_diff&.stored_externally? + merge_request_diff.opening_external_diff do |file| + file.seek(external_diff_offset) + file.read(external_diff_size) + end + else + super + end + + binary? ? content.unpack('m0').first : content end end |