forked from ruby-git/ruby-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfsck_object.rb
More file actions
48 lines (42 loc) · 1.42 KB
/
fsck_object.rb
File metadata and controls
48 lines (42 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true
module Git
# 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
#
class FsckObject
# The type of the Git object
# @return [Symbol] one of :commit, :tree, :blob, or :tag
attr_reader :type
# The object identifier (OID) of the object
# @return [String] the 40-character object identifier
attr_reader :oid
# A warning or error message associated with this object
# @return [String, nil] the message, or nil if no message
attr_reader :message
# A name describing how the object is reachable (from --name-objects)
# @return [String, nil] the name, or nil if not provided
attr_reader :name
# Create a new FsckObject
#
# @param type [Symbol] the object type (:commit, :tree, :blob, or :tag)
# @param oid [String] the 40-character object identifier
# @param message [String, nil] optional warning/error message
# @param name [String, nil] optional name from --name-objects (e.g., "HEAD~2^2:src/")
#
def initialize(type:, oid:, message: nil, name: nil)
@type = type
@oid = oid
@message = message
@name = name
end
# Returns the OID as the string representation
# @return [String] the object identifier
def to_s
oid
end
end
end