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.

API:

  • public

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Create a new FsckObject

Parameters:

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

  • the 40-character SHA-1 hash

  • (defaults to: nil)

    optional warning/error message

  • (defaults to: nil)

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

API:

  • public



35
36
37
38
39
40
# File 'lib/git/fsck_object.rb', line 35

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

Instance Attribute Details

#messageString? (readonly)

A warning or error message associated with this object

Returns:

  • the message, or nil if no message

API:

  • public



22
23
24
# File 'lib/git/fsck_object.rb', line 22

def message
  @message
end

#nameString? (readonly)

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

Returns:

  • the name, or nil if not provided

API:

  • public



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

def name
  @name
end

#shaString (readonly)

The SHA-1 hash of the object

Returns:

  • the 40-character SHA-1 hash

API:

  • public



18
19
20
# File 'lib/git/fsck_object.rb', line 18

def sha
  @sha
end

#typeSymbol (readonly)

The type of the Git object

Returns:

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

API:

  • public



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

def type
  @type
end

Instance Method Details

#to_sString

Returns the SHA as the string representation

Returns:

  • the SHA-1 hash

API:

  • public



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

def to_s
  sha
end