3 class Gitalist::Git::Object {
4 use MooseX::Types::Moose qw/Str Int/;
5 use File::Stat::ModeString qw/mode_to_string/;
6 # project and sha1 are required initargs
7 has project => ( isa => 'Gitalist::Git::Project',
10 handles => [ 'run_cmd' ],
12 has sha1 ( isa => Str,
16 has $_ => ( isa => Str,
20 for qw/type modestr size/;
22 # objects can't determine their mode or filename
23 has file => ( isa => Str,
26 has mode => ( isa => Int,
32 $self->$_() for qw/type modestr size/; # Ensure to build early.
36 my $output = $self->run_cmd(qw/cat-file -t/, $self->{sha1});
41 method _build_modestr {
42 my $modestr = mode_to_string($self->{mode});
47 my $output = $self->run_cmd(qw/cat-file -s/, $self->{sha1});
54 Return the contents of a given file.
59 if ( $self->type ne 'blob' ) {
60 die "object $self->sha1 is not a file\n"
63 my $output = $self->run_cmd(qw/cat-file -p/, $self->sha1);
64 return unless $output;