Module: Git::Parsers::Fsck Private
- Defined in:
- lib/git/parsers/fsck.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Parser for git fsck command output
Handles parsing of git fsck output into structured data objects
for dangling, missing, unreachable objects, warnings, roots, and tagged objects.
Design Note: Namespace Organization
This parser creates and returns FsckObject and FsckResult
objects, which live at the top-level Git:: namespace rather than within
Git::Parsers::. This is intentional:
- Parsers are infrastructure - marked
@api private, users shouldn't interact with them directly - Result classes are public API - returned by commands and used throughout the codebase
- FsckObject and FsckResult represent operation outcomes - they describe repository integrity status, not parsing details
Keeping these classes at Git:: improves discoverability and correctly
reflects their role as public types rather than parser internals.
Constant Summary collapse
- OBJECT_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Pattern matcher for dangling/missing/unreachable object lines Matches lines like: dangling commit abc123... missing blob def456... unreachable tree 789abc... (name)
/\A(dangling|missing|unreachable) (\w+) ([0-9a-f]{40})(?: \((.+)\))?\z/- WARNING_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Pattern matcher for warning lines Matches lines like: warning in commit abc123...: message here
/\Awarning in (\w+) ([0-9a-f]{40}): (.+)\z/- ROOT_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Pattern matcher for root commit lines Matches lines like: root abc123...
/\Aroot ([0-9a-f]{40})\z/- TAGGED_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Pattern matcher for tagged object lines Matches lines like: tagged commit abc123... (tagname) in def456...
/\Atagged (\w+) ([0-9a-f]{40}) \((.+)\) in ([0-9a-f]{40})\z/
Class Method Summary collapse
-
.parse(stdout) ⇒ Git::FsckResult
private
Parse git fsck output into a FsckResult object.
-
.parse_line(line, result) ⇒ Boolean
private
Parse a single line of fsck output.
-
.parse_object_line(line, result) ⇒ Boolean
private
Parse a dangling/missing/unreachable object line.
-
.parse_root_line(line, result) ⇒ Boolean
private
Parse a root line.
-
.parse_tagged_line(line, result) ⇒ Boolean
private
Parse a tagged line.
-
.parse_warning_line(line, result) ⇒ Boolean
private
Parse a warning line.
Class Method Details
.parse(stdout) ⇒ Git::FsckResult
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.
Parse git fsck output into a FsckResult object
65 66 67 68 69 |
# File 'lib/git/parsers/fsck.rb', line 65 def parse(stdout) result = { dangling: [], missing: [], unreachable: [], warnings: [], root: [], tagged: [] } stdout.each_line { |line| parse_line(line.strip, result) } Git::FsckResult.new(**result) end |
.parse_line(line, result) ⇒ 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.
Parse a single line of fsck output
77 78 79 80 81 82 |
# File 'lib/git/parsers/fsck.rb', line 77 def parse_line(line, result) parse_object_line(line, result) || parse_warning_line(line, result) || parse_root_line(line, result) || parse_tagged_line(line, result) end |
.parse_object_line(line, result) ⇒ 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.
Parse a dangling/missing/unreachable object line
90 91 92 93 94 |
# File 'lib/git/parsers/fsck.rb', line 90 def parse_object_line(line, result) return unless (match = OBJECT_PATTERN.match(line)) result[match[1].to_sym] << Git::FsckObject.new(type: match[2].to_sym, oid: match[3], name: match[4]) end |
.parse_root_line(line, result) ⇒ 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.
Parse a root line
114 115 116 117 118 |
# File 'lib/git/parsers/fsck.rb', line 114 def parse_root_line(line, result) return unless (match = ROOT_PATTERN.match(line)) result[:root] << Git::FsckObject.new(type: :commit, oid: match[1]) end |
.parse_tagged_line(line, result) ⇒ 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.
Parse a tagged line
126 127 128 129 130 |
# File 'lib/git/parsers/fsck.rb', line 126 def parse_tagged_line(line, result) return unless (match = TAGGED_PATTERN.match(line)) result[:tagged] << Git::FsckObject.new(type: match[1].to_sym, oid: match[2], name: match[3]) end |
.parse_warning_line(line, result) ⇒ 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.
Parse a warning line
102 103 104 105 106 |
# File 'lib/git/parsers/fsck.rb', line 102 def parse_warning_line(line, result) return unless (match = WARNING_PATTERN.match(line)) result[:warnings] << Git::FsckObject.new(type: match[1].to_sym, oid: match[2], message: match[3]) end |