Native/Commit.pm untested

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