Welcome to mirror list, hosted at ThFree Co, Russian Federation.

merge_request_diff_file.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1199ff5af2281f1b7c2744d0005eac0dd801c9ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class MergeRequestDiffFile < ActiveRecord::Base
  include Gitlab::EncodingHelper

  belongs_to :merge_request_diff

  def utf8_diff
    return '' if diff.blank?

    encode_utf8(diff) if diff.respond_to?(:encoding)
  end

  def diff
    binary? ? super.unpack('m0').first : super
  end

  def to_hash
    keys = Gitlab::Git::Diff::SERIALIZE_KEYS - [:diff]

    as_json(only: keys).merge(diff: diff).with_indifferent_access
  end
end