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 # repository and sha1 are required initargs
9 has repository => ( isa => 'Gitalist::Git::Repository',
14 _run_cmd => 'run_cmd',
15 _run_cmd_fh => 'run_cmd_fh',
16 _run_cmd_list => 'run_cmd_list',
17 _get_gpp_object => 'get_gpp_object',
20 has sha1 => ( isa => NonEmptySimpleStr,
24 has type => ( isa => NonEmptySimpleStr,
28 has $_ => ( isa => NonEmptySimpleStr,
34 has _gpp_obj => ( isa => 'Git::PurePerl::Object',
38 handles => [ 'content' ],
41 # objects can't determine their mode or filename
42 has file => ( isa => NonEmptySimpleStr,
45 has mode => ( isa => Int,
50 method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
55 method _build__gpp_obj {
56 return $self->_get_gpp_object($self->sha1)
59 method "_build_size" {
60 my $v = $self->_cat_file_with_flag('s');
65 method _cat_file_with_flag ($flag) {
66 $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
69 method _build_modestr {
70 return _mode_str($self->mode);
73 # via gitweb.pm circa line 1305
76 S_IFINVALID => 0030000,
77 S_IFGITLINK => 0160000,
80 # submodule/subrepository, a commit object reference
82 return (($_[0] & S_IFMT) == S_IFGITLINK)
85 # convert file mode in octal to symbolic file mode string
89 if (S_ISGITLINK($mode)) {
91 } elsif (S_ISDIR($mode & S_IFMT)) {
93 } elsif (S_ISLNK($mode)) {
95 } elsif (S_ISREG($mode)) {
96 # git cares only about the executable bit
97 if ($mode & S_IXUSR) {
113 Gitalist::Git::Object - Model of a git object.
117 my $object = Repository->get_object($sha1);
121 Abstract base class for git objects.
132 See L<Gitalist> for authors.
136 See L<Gitalist> for the license.