Class: Git::FileDiffInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/git/diff_info.rb

Overview

Immutable value object representing a single file's diff information

FileDiffInfo encapsulates the parsed data from a unified diff for one file, including the file path, patch text, mode changes, object identifiers, and type.

This class is used by DiffInfo for the legacy diff API.

Examples:

Create a FileDiffInfo from parsed diff output

diff_info = Git::FileDiffInfo.new(
  path: 'lib/example.rb',
  patch: "diff --git a/lib/example.rb b/lib/example.rb\n...",
  mode: '100644',
  src: 'abc1234',
  dst: 'def5678',
  type: 'modified',
  binary: false
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary

Returns:

  • (Object)

    the current value of binary



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#dstObject (readonly)

Returns the value of attribute dst

Returns:

  • (Object)

    the current value of dst



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#modeObject (readonly)

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of mode



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#patchObject (readonly)

Returns the value of attribute patch

Returns:

  • (Object)

    the current value of patch



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#srcObject (readonly)

Returns the value of attribute src

Returns:

  • (Object)

    the current value of src



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/diff_info.rb', line 45

FileDiffInfo = Data.define(
  :path,
  :patch,
  :mode,
  :src,
  :dst,
  :type,
  :binary
) do
  # Check if this is a binary file
  #
  # @return [Boolean] true if the file is binary
  #
  def binary?
    binary
  end
end

Instance Method Details

#binary?Boolean

Check if this is a binary file

Returns:

  • (Boolean)

    true if the file is binary



58
59
60
# File 'lib/git/diff_info.rb', line 58

def binary?
  binary
end