class
Agate::Branch
- Agate::Branch
- Agate::Reference
- Reference
- Object
Overview
Represents a git branch (a reference under refs/heads/ or refs/remotes/).
Defined in:
agate/branch.crConstructors
-
.lookup(repo : Repository, name : String, type : Filter = Filter::Local) : Branch
Looks up a branch by name.
Class Method Summary
-
.lookup?(repo : Repository, name : String, type : Filter = Filter::Local) : Branch | Nil
Looks up a branch by name, returning nil if not found.
-
.valid_name?(name : String) : Bool
Returns true if the given name is a valid branch name.
Instance Method Summary
-
#canonical_name : String
Returns the full reference name (e.g., "refs/heads/master").
-
#checked_out? : Bool
Returns true if this branch is checked out in any worktree.
-
#head? : Bool
Returns true if this branch is the current HEAD.
-
#name : String
Returns the short branch name (e.g., "master" instead of "refs/heads/master").
-
#remote : Remote | Nil
Returns the Remote object for a remote-tracking branch, or nil.
-
#remote_name : String | Nil
Returns the remote name for a remote-tracking branch, or nil.
-
#upstream : Branch | Nil
Returns the upstream branch, or nil if none is set.
-
#upstream=(branch_name : String | Nil) : Nil
Sets the upstream branch name.
Instance methods inherited from class Agate::Reference
<=>(other : Reference) : Int32
<=>,
==(other : Reference) : Bool
==,
branch? : Bool
branch?,
log : Array(ReflogEntry)
log,
log? : Bool
log?,
name : String
name,
note? : Bool
note?,
owner : Repository
owner,
peel(target_type : Object::Type = Object::Type::Any) : Object
peel,
remote? : Bool
remote?,
resolve : Reference
resolve,
shorthand : String
shorthand,
symbolic_target : String | Nil
symbolic_target,
tag? : Bool
tag?,
target_id : OID
target_id,
target_id? : OID | Nil
target_id?,
type : Type
type,
update(target : OID, log_message : String = "") : Reference
update
Constructor methods inherited from class Agate::Reference
dwim(repo : Repository, shorthand : String) : Reference
dwim,
lookup(repo : Repository, name : String) : Reference
lookup
Class methods inherited from class Agate::Reference
dwim?(repo : Repository, shorthand : String) : Reference | Nil
dwim?,
lookup?(repo : Repository, name : String) : Reference | Nil
lookup?,
valid_name?(name : String) : Bool
valid_name?
Constructor Detail
Looks up a branch by name. Raises on failure.
Class Method Detail
Looks up a branch by name, returning nil if not found.
Instance Method Detail
Returns the Remote object for a remote-tracking branch, or nil.
branch = repo.branches["origin/main"]
remote = branch.remote # => Remote("origin")