| 1 | package Git::Repository::Log; | ||||||||||||
| 2 | 6 | $Git::Repository::Log::VERSION = '1.314'; | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 6 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | # a few simple accessors | ||||||||||||
| 8 | 6 | for my $attr ( | |||||||||||
| 9 | qw( | ||||||||||||
| 10 | commit diff_from tree | ||||||||||||
| 11 | author author_name author_email | ||||||||||||
| 12 | committer committer_name committer_email | ||||||||||||
| 13 | author_localtime author_tz author_gmtime | ||||||||||||
| 14 | committer_localtime committer_tz committer_gmtime | ||||||||||||
| 15 | raw_message message subject body | ||||||||||||
| 16 | gpgsig | ||||||||||||
| 17 | extra | ||||||||||||
| 18 | ) | ||||||||||||
| 19 | ) | ||||||||||||
| 20 | { | ||||||||||||
| 21 | 6 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 207 | ▶ | *$attr = sub { return $_[0]{$attr} }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | } | ||||||||||||
| 24 | 6 | for my $attr (qw( parent mergetag )) { | |||||||||||
| 25 | 6 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | 73 | ▶ | *$attr = sub { return @{ $_[0]{$attr} || [] } }; | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]{$attr} || []
MC/DC100%1/1
$_[0]{$attr} || []
$_[0]{$attr}
Truth table100%2/2
A
A= $_[0]{$attr}
| |||||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 43 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||
| 30 | 43 | my ( $class, @args ) = @_; | |||||||||||
| 31 | 43 | my $self = bless { parent => [] }, $class; | |||||||||||
| 32 | |||||||||||||
| 33 | # pick up key/values from the list | ||||||||||||
| 34 | 43 | ▶ | while ( my ( $key, $value ) = splice @args, 0, 2 ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | 344 | ▶ | if ( $key =~ /^(?:parent|mergetag)$/ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | 77 | push @{ $self->{$key} }, $value; | |||||||||||
| 37 | } | ||||||||||||
| 38 | else { | ||||||||||||
| 39 | 267 | $self->{$key} = $value; | |||||||||||
| 40 | } | ||||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | # special case | ||||||||||||
| 44 | 43 | ($self->{commit}, $self->{diff_from}) = $self->{commit} =~ /^(\S+)(?: \(from (\S+)\))?/; | |||||||||||
| 45 | |||||||||||||
| 46 | # compute other keys | ||||||||||||
| 47 | 43 | $self->{raw_message} = $self->{message}; | |||||||||||
| 48 | 43 | $self->{message} =~ s/^ //gm; | |||||||||||
| 49 | 43 | @{$self}{qw( subject body )} | |||||||||||
| 50 | 43 | = ( split( /\n/m, $self->{message}, 2 ), '', '' ); | |||||||||||
| 51 | 43 | $self->{body} =~ s/\A\s//gm; | |||||||||||
| 52 | |||||||||||||
| 53 | # author and committer details | ||||||||||||
| 54 | 43 | for my $who (qw( author committer )) { | |||||||||||
| 55 | 86 | $self->{$who} =~ /^(.*) <(.*)> (.*) (([-+])(..)(..))$/; | |||||||||||
| 56 | 86 | my @keys = ( "${who}_name", "${who}_email", "${who}_gmtime", | |||||||||||
| 57 | "${who}_tz" ); | ||||||||||||
| 58 | 86 | @{$self}{@keys} = ( $1, $2, $3, $4 ); | |||||||||||
| 59 | 86 | ▶ | $self->{"${who}_localtime"} = $self->{"${who}_gmtime"} | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | + ( $5 eq '-' ? -1 : 1 ) * ( $6 * 3600 + $7 * 60 ); | ||||||||||||
| 61 | } | ||||||||||||
| 62 | |||||||||||||
| 63 | 43 | return $self; | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 6 | 1; | |||||||||||
| 67 | |||||||||||||
| 68 | __END__ | ||||||||||||