4 class Gitalist::Git::Object {
5 use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
6 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
8 with 'Gitalist::Serializeable';
10 # repository and sha1 are required initargs
11 has repository => ( isa => 'Gitalist::Git::Repository',
16 _run_cmd => 'run_cmd',
17 _run_cmd_fh => 'run_cmd_fh',
18 _run_cmd_list => 'run_cmd_list',
19 _get_gpp_object => 'get_gpp_object',
22 has sha1 => ( isa => NonEmptySimpleStr,
26 has type => ( isa => NonEmptySimpleStr,
30 has $_ => ( isa => NonEmptySimpleStr,
36 has _gpp_obj => ( isa => 'Git::PurePerl::Object',
40 handles => [ 'content' ],
41 traits => [qw/ DoNotSerialize /],
44 # objects can't determine their mode or filename
45 has file => ( isa => NonEmptySimpleStr,
48 has mode => ( isa => Int,
53 method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
58 method _build__gpp_obj {
59 return $self->_get_gpp_object($self->sha1)
62 method "_build_size" {
63 my $v = $self->_cat_file_with_flag('s');
68 method _cat_file_with_flag ($flag) {
69 $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
72 method _build_modestr {
73 return _mode_str($self->mode);
76 # via gitweb.pm circa line 1305
79 S_IFINVALID => 0030000,
80 S_IFGITLINK => 0160000,
83 # submodule/subrepository, a commit object reference
85 return (($_[0] & S_IFMT) == S_IFGITLINK)
88 # convert file mode in octal to symbolic file mode string
92 if (S_ISGITLINK($mode)) {
94 } elsif (S_ISDIR($mode & S_IFMT)) {
96 } elsif (S_ISLNK($mode)) {
98 } elsif (S_ISREG($mode)) {
99 # git cares only about the executable bit
100 if ($mode & S_IXUSR) {
116 Gitalist::Git::Object - Model of a git object.
120 my $object = Repository->get_object($sha1);
124 Abstract base class for git objects.
135 See L<Gitalist> for authors.
139 See L<Gitalist> for the license.