Gitalist::Git::Object::HasTree - Gitalist::Git::Object::HasTree documentation


Gitalist documentation Contained in the Gitalist distribution.

Index


Code Index:

NAME

Top

Gitalist::Git::Object::HasTree

SYNOPSIS

Top

    my $tree = Repository->get_object($tree_sha1);

DESCRIPTION

Top

Role for objects which have a tree - Commit and Tree objects.

ATTRIBUTES

Top

tree

METHODS

Top

AUTHORS

Top

See Gitalist for authors.

LICENSE

Top

See Gitalist for the license.


Gitalist documentation Contained in the Gitalist distribution.

package Gitalist::Git::Object::HasTree;
use MooseX::Declare;

role Gitalist::Git::Object::HasTree {
    has tree => ( isa => 'ArrayRef[Gitalist::Git::Object]',
                  required => 0,
                  is => 'ro',
                  lazy_build => 1 );


## Builders
    method _build_tree {
        my $output = $self->_run_cmd(qw/ls-tree -z/, $self->sha1);
        return unless defined $output;

        my @ret;
        for my $line (split /\0/, $output) {
            my ($mode, $type, $object, $file) = split /\s+/, $line, 4;
            my $class = 'Gitalist::Git::Object::' . ucfirst($type);
            push @ret, $class->new( mode => oct $mode,
                                    type => $type,
                                    sha1 => $object,
                                    file => $file,
                                    repository => $self->repository,
                                  );
        }
        return \@ret;
    }

}

1;


1;

__END__