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:, sha:, message: nil, name: nil) ⇒ FsckObject

Create a new FsckObject

Parameters:

  • type (Symbol)

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

  • sha (String)

    the 40-character SHA-1 hash

  • 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/")



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:

  • (String, nil)

    the message, or nil if no message



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:

  • (String, nil)

    the name, or nil if not provided



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:

  • (String)

    the 40-character SHA-1 hash



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

def sha
  @sha
end

#typeSymbol (readonly)

The type of the Git object

Returns:

  • (Symbol)

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



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:

  • (String)

    the SHA-1 hash



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

def to_s
  sha
end