class Git::FsckResult
Represents the result of running โgit fsck`
This class provides structured access to the objects found during a repository integrity check, categorized by their status.
@api public
Attributes
Objects not referenced by any other object
@return [Array<Git::FsckObject>]
Objects that are referenced but not present in the repository
@return [Array<Git::FsckObject>]
Root nodes (commits with no parents) when โroot is used
@return [Array<Git::FsckObject>]
Tagged objects when โtags is used
@return [Array<Git::FsckObject>]
Objects not reachable from any ref
@return [Array<Git::FsckObject>]
Objects with warnings (each includes a message)
@return [Array<Git::FsckObject>]
Public Class Methods
Source
# File lib/git/fsck_result.rb, line 58 def initialize(dangling: [], missing: [], unreachable: [], warnings: [], root: [], tagged: []) @dangling = dangling @missing = missing @unreachable = unreachable @warnings = warnings @root = root @tagged = tagged end
Create a new FsckResult
@param dangling [Array<Git::FsckObject>] dangling objects
@param missing [Array<Git::FsckObject>] missing objects
@param unreachable [Array<Git::FsckObject>] unreachable objects
@param warnings [Array<Git::FsckObject>] objects with warnings
@param root [Array<Git::FsckObject>] root nodes
@param tagged [Array<Git::FsckObject>] tagged objects
Public Instance Methods
Source
# File lib/git/fsck_result.rb, line 101 def all_objects dangling + missing + unreachable + warnings end
Returns all objects from all categories (excluding informational root/tagged)
@example Iterate over all objects
result = git.fsck result.all_objects.each { |obj| puts obj.oid }
@return [Array<Git::FsckObject>]
Source
# File lib/git/fsck_result.rb, line 77 def any_issues? [dangling, missing, unreachable, warnings].any?(&:any?) end
Returns true if any issues were found
@example Check for repository issues
result = git.fsck puts "Repository has issues!" if result.any_issues?
@return [Boolean]
Source
# File lib/git/fsck_result.rb, line 113 def count all_objects.size end
Returns the total number of issues found
@example Count all issues
result = git.fsck puts "Found #{result.count} issues"
@return [Integer]
Source
# File lib/git/fsck_result.rb, line 89 def empty? !any_issues? end
Returns true if no issues were found
@example Check if the result is empty
result = git.fsck puts "Repository is clean" if result.empty?
@return [Boolean]
Source
# File lib/git/fsck_result.rb, line 125 def to_h { dangling: dangling, missing: missing, unreachable: unreachable, warnings: warnings, root: root, tagged: tagged } end
Returns a hash representation of the result
@example Convert to a hash
result = git.fsck result.to_h # => { dangling: [...], missing: [...], ... }
@return [Hash{Symbol => Array<Git::FsckObject>}]