Class: Git::FsckObject

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

Overview

Represents an object returned by git fsck

This class provides information about dangling, missing, unreachable, or problematic Git objects found during repository integrity checks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, oid:, message: nil, name: nil) ⇒ FsckObject

Create a new FsckObject

Parameters:

  • type (Symbol)

    the object type (:commit, :tree, :blob, or :tag)

  • oid (String)

    the 40-character object identifier

  • message (String, nil) (defaults to: nil)

    optional warning/error message

  • name (String, nil) (defaults to: nil)

    optional name from --name-objects (e.g., "HEAD~2^2:src/")



42
43
44
45
46
47
# File 'lib/git/fsck_object.rb', line 42

def initialize(type:, oid:, message: nil, name: nil)
  @type = type
  @oid = oid
  @message = message
  @name = name
end

Instance Attribute Details

#messageString? (readonly)

A warning or error message associated with this object

Returns:

  • (String, nil)

    the message, or nil if no message



25
26
27
# File 'lib/git/fsck_object.rb', line 25

def message
  @message
end

#nameString? (readonly)

A name describing how the object is reachable (from --name-objects)

Returns:

  • (String, nil)

    the name, or nil if not provided



30
31
32
# File 'lib/git/fsck_object.rb', line 30

def name
  @name
end

#oidString (readonly)

The object identifier (OID) of the object

Returns:

  • (String)

    the 40-character object identifier



20
21
22
# File 'lib/git/fsck_object.rb', line 20

def oid
  @oid
end

#typeSymbol (readonly)

The type of the Git object

Returns:

  • (Symbol)

    one of :commit, :tree, :blob, or :tag



15
16
17
# File 'lib/git/fsck_object.rb', line 15

def type
  @type
end

Instance Method Details

#to_sString

Returns the OID as the string representation

Returns:

  • (String)

    the object identifier



52
53
54
# File 'lib/git/fsck_object.rb', line 52

def to_s
  oid
end