class
Agate::Reference
- Agate::Reference
- Reference
- Object
Overview
A git reference (branch, tag, or symbolic pointer).
Included Modules
- Comparable(Agate::Reference)
Direct Known Subclasses
Defined in:
agate/reflog.cragate/refs.cr
Constructors
-
.dwim(repo : Repository, shorthand : String) : Reference
Looks up a reference using dwim (Do What I Mean) rules.
-
.lookup(repo : Repository, name : String) : Reference
Looks up a reference by name.
Class Method Summary
-
.dwim?(repo : Repository, shorthand : String) : Reference | Nil
Looks up a reference using dwim rules, returning nil if not found.
-
.lookup?(repo : Repository, name : String) : Reference | Nil
Looks up a reference by name, returning nil if not found.
-
.valid_name?(name : String) : Bool
Returns true if the given name is a valid reference name.
Instance Method Summary
-
#<=>(other : Reference) : Int32
Compares two references.
-
#==(other : Reference) : Bool
Equality comparison.
-
#branch? : Bool
Returns true if this reference is a local branch.
-
#log : Array(ReflogEntry)
Returns the reflog entries for this reference.
-
#log? : Bool
Returns true if this reference has a reflog.
-
#name : String
Returns the full reference name (e.g., "refs/heads/master").
-
#note? : Bool
Returns true if this reference is a note.
-
#owner : Repository
Returns the repository that owns this reference.
-
#peel(target_type : Object::Type = Object::Type::Any) : Object
Peels the reference to an object of the given type.
-
#remote? : Bool
Returns true if this reference is a remote tracking branch.
-
#resolve : Reference
Resolves a symbolic reference to a direct reference.
-
#shorthand : String
Returns the short name (e.g., "master" from "refs/heads/master").
-
#symbolic_target : String | Nil
Returns the target name for symbolic references.
-
#tag? : Bool
Returns true if this reference is a tag.
-
#target_id : OID
Returns the target OID for direct references.
-
#target_id? : OID | Nil
Returns the target OID for direct references.
-
#type : Type
Returns the reference type (:direct or :symbolic).
-
#update(target : OID, log_message : String = "") : Reference
Updates the target of this direct reference.
Constructor Detail
Looks up a reference using dwim (Do What I Mean) rules. E.g., "master" resolves to "refs/heads/master". Raises on failure.
Looks up a reference by name. Raises on failure.
Class Method Detail
Looks up a reference using dwim rules, returning nil if not found.
Looks up a reference by name, returning nil if not found.
Returns true if the given name is a valid reference name.
Instance Method Detail
Returns the reflog entries for this reference.
ref = repo.references["refs/heads/main"]
ref.log.each do |entry|
puts "#{entry.old_id.to_s[..7]} -> #{entry.new_id.to_s[..7]}: #{entry.message}"
end
Peels the reference to an object of the given type.
Resolves a symbolic reference to a direct reference. For direct references, returns a copy.
Returns the target name for symbolic references. Returns nil for direct references.
Returns the target OID for direct references. Raises for symbolic references.
Returns the target OID for direct references. Returns nil for symbolic references.
Updates the target of this direct reference. Returns the new reference.