Native/Commit.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 64 CC 2 SCAR 9.2
CC
2
Cov
0%
DEMOLISH
6.0
_build_oid
2.0
message
2.0
CRAP 2.5
1 # ABSTRACT: A libgit2 commit object
2  
3 package Git::Native::Commit;
4 use Moo;
5 use Git::Libgit2 qw( check_rc );
6 use Git::Libgit2::FFI ();
7 use Git::Native::Oid ();
8 use Git::Native::Tree ();
9  
10 has _handle => ( is => 'ro', required => 1 );
11 has _owner => ( is => 'ro', required => 1 ); # Repository
12  
13 has oid => ( is => 'lazy' );
14 sub _build_oid {
15 Git::Native::Oid->from_ptr(
16 Git::Libgit2::FFI::git_object_id( $_[0]->_handle )
17 );
18 }
19  
20 sub message {
21 Git::Libgit2::FFI::git_commit_message( $_[0]->_handle );
22 }
23  
24 # First paragraph of the message, whitespace-collapsed (libgit2-side).
25 sub summary {
26 Git::Libgit2::FFI::git_commit_summary( $_[0]->_handle );
27 }
28  
29 # Commit time as a Unix epoch (committer's time).
30 sub time {
31 Git::Libgit2::FFI::git_commit_time( $_[0]->_handle );
32 }
33  
34 # Timezone offset of the commit time, in minutes east of UTC.
35 sub time_offset {
36 Git::Libgit2::FFI::git_commit_time_offset( $_[0]->_handle );
37 }
38  
39 sub tree {
40 my $self = shift;
41 check_rc Git::Libgit2::FFI::git_commit_tree( \my $t, $self->_handle );
42 return Git::Native::Tree->new( _handle => $t, _owner => $self->_owner );
43 }
44  
45 sub tree_oid {
46 Git::Native::Oid->from_ptr(
47 Git::Libgit2::FFI::git_commit_tree_id( $_[0]->_handle )
48 );
49 }
50  
51 sub parent_count {
52 Git::Libgit2::FFI::git_commit_parentcount( $_[0]->_handle );
53 }
54  
55 sub parent_oids {
56 my $self = shift;
57 my @out;
58 my $n = $self->parent_count;
59 for my $i ( 0 .. $n - 1 ) {
60 push @out, Git::Native::Oid->from_ptr(
61 Git::Libgit2::FFI::git_commit_parent_id( $self->_handle, $i )
62 );
63 }
64 return \@out;
65 }
66  
67 sub DEMOLISH {
68 my $self = shift;
69 Git::Libgit2::FFI::git_commit_free( $self->{_handle} ) if $self->{_handle};
70 }
71  
72 1;
73  
74 __END__