class Git::Object::AbstractObject::Tree
A Git tree object
Public Class Methods
Source
# File lib/git/object.rb, line 299 def initialize(base, sha, mode = nil) super(base, sha) @mode = mode @trees = nil @blobs = nil end
Creates a tree object wrapper
@param base [Git::Repository] the repository used to query object data
@param sha [String] the tree SHA or object expression
@param mode [String, nil] the file mode from tree listings
Git::Object::AbstractObject::new
Public Instance Methods
Source
# File lib/git/object.rb, line 318 def blobs @blobs ||= check_tree[:blobs] end
Returns blobs directly under this tree
@return [Hash<String, Git::Object::Blob>] blob objects by filename
Source
# File lib/git/object.rb, line 310 def children blobs.merge(subtrees) end
Returns child blobs and subtrees keyed by name
@return [Hash<String, Git::Object::AbstractObject>] child objects by name
Source
# File lib/git/object.rb, line 345 def depth object_repository.tree_depth(@objectish) end
Returns the maximum depth of this tree
@return [Integer] maximum tree depth
Source
# File lib/git/object.rb, line 337 def full_tree object_repository.full_tree(@objectish) end
Returns the full tree listing for this tree
@return [Hash] parsed recursive tree data
Source
# File lib/git/object.rb, line 353 def tree? true end
Returns whether this object is a tree
@return [Boolean] ‘true`
Source
# File lib/git/object.rb, line 327 def trees @trees ||= check_tree[:trees] end
Returns subtrees directly under this tree
@return [Hash<String, Git::Object::Tree>] subtree objects by directory name
Private Instance Methods
Source
# File lib/git/object.rb, line 360 def check_tree @trees = {} @blobs = {} data = object_repository.ls_tree(@objectish) data['tree'].each do |key, tree| @trees[key] = Git::Object::Tree.new(@base, tree[:sha], tree[:mode]) end data['blob'].each do |key, blob| @blobs[key] = Git::Object::Blob.new(@base, blob[:sha], blob[:mode]) end { trees: @trees, blobs: @blobs } end
actually run the git command