Class: NoteDiffFile

Inherits:
ApplicationRecord show all
Includes:
DiffFile, Gitlab::EncodingHelper, Importable, Notes::WithAssociatedNote
Defined in:
app/models/note_diff_file.rb

Constant Summary

Constants included from Gitlab::EncodingHelper

Gitlab::EncodingHelper::BOM_UTF8, Gitlab::EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, Gitlab::EncodingHelper::ESCAPED_CHARS, Gitlab::EncodingHelper::UNICODE_REPLACEMENT_CHARACTER

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Attribute Summary

Attributes included from Importable

#importing, #user_contributions

Instance Method Summary collapse

Methods included from Gitlab::EncodingHelper

#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #force_encode_utf8, #strip_bom, #unquote_path

Methods included from DiffFile

#to_hash

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Instance Method Details

#diff_exportObject



30
31
32
33
34
# File 'app/models/note_diff_file.rb', line 30

def diff_export
  force_encode_utf8(diff)
rescue ArgumentError
  diff
end

#raw_diff_fileObject



19
20
21
22
23
24
25
26
27
28
# File 'app/models/note_diff_file.rb', line 19

def raw_diff_file
  raw_diff = Gitlab::Git::Diff.new(to_hash)

  Gitlab::Diff::File.new(
    raw_diff,
    repository: project.repository,
    diff_refs: original_position.diff_refs,
    unique_identifier: id
  )
end