Commit | Line | Data |
0250a92d |
1 | package Gitalist::Git::Object::HasTree; |
2 | use MooseX::Declare; |
3 | |
4 | role Gitalist::Git::Object::HasTree { |
5 | has tree => ( isa => 'ArrayRef[Gitalist::Git::Object]', |
6 | required => 0, |
7 | is => 'ro', |
8 | lazy_build => 1 ); |
9 | |
10 | |
11 | ## Builders |
12 | method _build_tree { |
13 | my $output = $self->_run_cmd(qw/ls-tree -z/, $self->sha1); |
14 | return unless defined $output; |
15 | |
16 | my @ret; |
17 | for my $line (split /\0/, $output) { |
18 | my ($mode, $type, $object, $file) = split /\s+/, $line, 4; |
19 | my $class = 'Gitalist::Git::Object::' . ucfirst($type); |
20 | push @ret, $class->new( mode => oct $mode, |
21 | type => $type, |
22 | sha1 => $object, |
23 | file => $file, |
82bc0f05 |
24 | repository => $self->repository, |
0250a92d |
25 | ); |
26 | } |
27 | return \@ret; |
28 | } |
29 | |
30 | } |
775e96e0 |
31 | |
32 | 1; |
33 | |
34 | |
35 | 1; |
36 | |
37 | __END__ |
38 | |
39 | =head1 NAME |
40 | |
2298d93f |
41 | Gitalist::Git::Object::HasTree - Git::Object::HasTree module for Gitalist |
775e96e0 |
42 | |
c19af0d0 |
43 | =head1 SYNOPSIS |
44 | |
44a9ed75 |
45 | my $tree = Repository->get_object($tree_sha1); |
c19af0d0 |
46 | |
775e96e0 |
47 | =head1 DESCRIPTION |
48 | |
c19af0d0 |
49 | Role for objects which have a tree - C<Commit> and C<Tree> objects. |
50 | |
51 | |
52 | =head1 ATTRIBUTES |
53 | |
54 | =head2 tree |
55 | |
56 | |
57 | =head1 METHODS |
58 | |
775e96e0 |
59 | |
60 | =head1 AUTHORS |
61 | |
62 | See L<Gitalist> for authors. |
63 | |
64 | =head1 LICENSE |
65 | |
66 | See L<Gitalist> for the license. |
67 | |
68 | =cut |