class
Agate::Tree
- Agate::Tree
- Reference
- Object
Overview
Represents a git tree object (directory listing).
Included Modules
- Enumerable(Agate::TreeEntry)
Defined in:
agate/tree.crConstructors
-
.lookup(repo : Repository, oid : OID) : Tree
Looks up a tree by OID.
Class Method Summary
-
.build(repo : Repository, source : Tree | Nil = nil, & : TreeBuilder -> ) : OID
Builds a new tree by yielding a TreeBuilder, then writes it and returns the OID.
-
.lookup?(repo : Repository, oid : OID) : Tree | Nil
Looks up a tree by OID, returning nil if not found.
Instance Method Summary
-
#[](index : Int32) : TreeEntry
Returns the entry at the given index.
-
#[](name : String) : TreeEntry
Returns the entry with the given name.
-
#[]?(name : String) : TreeEntry | Nil
Returns the entry with the given name, or nil.
-
#count : Int32
Returns the number of entries in this tree.
-
#diff(repo : Repository, other : Tree | Nil = nil) : Diff
Diffs this tree against another tree.
-
#each(& : TreeEntry -> ) : Nil
Iterates over all entries in this tree.
-
#each_blob(& : TreeEntry -> ) : Nil
Iterates over blob entries only.
-
#each_tree(& : TreeEntry -> ) : Nil
Iterates over tree (subdirectory) entries only.
-
#merge(repo : Repository, our_tree : Tree, their_tree : Tree) : Index
Three-way merge of this tree with another tree and an ancestor.
-
#oid : OID
Returns the OID of this tree.
-
#path(path : String) : TreeEntry
Returns the entry at the given path (can include '/').
-
#size : Int32
Alias for count.
-
#walk(mode : WalkMode = WalkMode::Pre, &block : String, TreeEntry -> ) : Nil
Recursively walks the tree in the given mode (:pre or :post order).
-
#walk_blobs(mode : WalkMode = WalkMode::Post, &block : String, TreeEntry -> ) : Nil
Recursively walks blobs only.
-
#walk_trees(mode : WalkMode = WalkMode::Pre, &block : String, TreeEntry -> ) : Nil
Recursively walks subtrees only.
Constructor Detail
Looks up a tree by OID. Raises on failure.
Class Method Detail
Builds a new tree by yielding a TreeBuilder, then writes it and returns the OID.
tree_oid = Tree.build(repo) do |b|
b.insert("README.md", readme_oid)
b.insert("src/main.cr", main_oid)
end
Looks up a tree by OID, returning nil if not found.
Instance Method Detail
Returns the entry with the given name. Raises KeyError if not found.
Returns the entry with the given name, or nil.
Diffs this tree against another tree.
Iterates over tree (subdirectory) entries only.
Three-way merge of this tree with another tree and an ancestor.
Returns the entry at the given path (can include '/'). The returned entry must be freed, so we read it immediately.
Recursively walks the tree in the given mode (:pre or :post order). Yields the root path (e.g., "src/") and each entry.
Recursively walks blobs only.
Recursively walks subtrees only.