4 class Gitalist::Git::Object with Gitalist::Git::Serializable is dirty {
5 use MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize;
7 use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
8 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
9 use overload '""' => '_to_string', fallback => 1;
11 # repository and sha1 are required initargs
12 has repository => ( isa => 'Gitalist::Git::Repository',
17 _run_cmd => 'run_cmd',
18 _run_cmd_fh => 'run_cmd_fh',
19 _run_cmd_list => 'run_cmd_list',
20 _get_gpp_object => 'get_gpp_object',
23 has sha1 => ( isa => NonEmptySimpleStr,
27 has type => ( isa => NonEmptySimpleStr,
31 has $_ => ( isa => NonEmptySimpleStr,
37 has _gpp_obj => ( isa => 'Git::PurePerl::Object',
41 handles => [ 'content' ],
42 traits => ['DoNotSerialize']
45 # objects can't determine their mode or filename
46 has file => ( isa => NonEmptySimpleStr,
49 has mode => ( isa => Int,
54 method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
62 method _build__gpp_obj {
63 return $self->_get_gpp_object($self->sha1)
66 method "_build_size" {
67 my $v = $self->_cat_file_with_flag('s');
72 method _cat_file_with_flag ($flag) {
73 $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
76 method _build_modestr {
77 return _mode_str($self->mode);
80 # via gitweb.pm circa line 1305
83 S_IFINVALID => 0030000,
84 S_IFGITLINK => 0160000,
87 # submodule/subrepository, a commit object reference
89 return (($_[0] & S_IFMT) == S_IFGITLINK)
92 # convert file mode in octal to symbolic file mode string
96 if (S_ISGITLINK($mode)) {
98 } elsif (S_ISDIR($mode & S_IFMT)) {
100 } elsif (S_ISLNK($mode)) {
102 } elsif (S_ISREG($mode)) {
103 # git cares only about the executable bit
104 if ($mode & S_IXUSR) {
120 Gitalist::Git::Object - Model of a git object.
124 my $object = Repository->get_object($sha1);
128 Abstract base class for git objects.
139 See L<Gitalist> for authors.
143 See L<Gitalist> for the license.