Class: Git::FileDiffInfo Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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.

Work in progress; this class is internal for now and may be made public in a future release.

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

#binaryBoolean (readonly)

Returns whether this is a binary file.

Returns:

  • (Boolean)

    whether this is a binary file



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

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

#dstString (readonly)

Returns the destination blob object identifier.

Returns:

  • (String)

    the destination blob object identifier



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

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

#modeString (readonly)

Returns the file mode (e.g., '100644' for regular files).

Returns:

  • (String)

    the file mode (e.g., '100644' for regular files)



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

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

#patchString (readonly)

Returns the full unified diff patch text for this file.

Returns:

  • (String)

    the full unified diff patch text for this file



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

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

#pathString (readonly)

Returns the file path relative to the repository root.

Returns:

  • (String)

    the file path relative to the repository root



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

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

#srcString (readonly)

Returns the source blob object identifier.

Returns:

  • (String)

    the source blob object identifier



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

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

#typeString (readonly)

Returns the type of change: 'modified', 'new', 'deleted', 'renamed'.

Returns:

  • (String)

    the type of change: 'modified', 'new', 'deleted', 'renamed'



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

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if this is a binary file

Returns:

  • (Boolean)

    true if the file is binary



60
61
62
# File 'lib/git/diff_info.rb', line 60

def binary?
  binary
end