Gitalist/Tag.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 95.3% 62 / 65 CC 4 SCAR 6.9
CC
4
Cov
98%
__ANON__
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Gitalist/HasUtils.pm ↑ Summary Gitalist/Head.pm »
1 package Git::Gitalist::Tag;
2  
3 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 with 'Git::Gitalist::Serializable';
7  
8 3 ▶use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use MooseX::Types::Moose qw/Maybe/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Git::Gitalist::Types qw/SHA1/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use MooseX::Types::DateTime qw/ DateTime /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use aliased 'DateTime' => 'DT';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 has sha1 => ( isa => SHA1,
16 is => 'ro',
17 required => 1,
18 );
19 3 has name => ( isa => NonEmptySimpleStr,
20 is => 'ro',
21 required => 1,
22 );
23  
24 3 has type => ( isa => NonEmptySimpleStr,
25 is => 'ro',
26 required => 1,
27 );
28  
29 3 has ref_sha1 => ( isa => Maybe[SHA1],
30 is => 'ro',
31 required => 0,
32 );
33 3 has ref_type => ( isa => Maybe[NonEmptySimpleStr],
34 is => 'ro',
35 required => 0,
36 );
37 3 has committer => ( isa => NonEmptySimpleStr,
38 is => 'ro',
39 required => 1,
40 );
41 3 has last_change => ( isa => Maybe[DateTime],
42 is => 'ro',
43 required => 1,
44 );
45  
46 3 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
47 3 my $orig = shift;
48 3 my $class = shift;
49  
50 3 ▶ if ( @_ == 1 && ! ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and not ref $_[0]) { } 2 1 3
Condition66%2/3
@_ == 1 and not ref $_[0]
!ll&&!rl&&r
102
MC/DC50%1/2
@_ == 1 and not ref $_[0]
@_ == 1 not ref $_[0]
Truth table66%2/3
A and not(B)
A= @_ == 1B= not ref $_[0]
ABresult
0X0
100
111
51 2 my $line = $_[0];
52 # expects $line to match the output from
53 # --format=%(objectname) %(objecttype) %(refname) %(*objectname) %(*objecttype) %(subject)%00%(creator)
54 2 my ($sha1, $type, $name, $ref_sha1, $ref_type, $rest) = split / /, $line, 6;
55 2 $name =~ s!^refs/tags/!!;
56  
57 2 ▶ unless ($ref_sha1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref_sha1) 1 1 2
58 1 ($ref_sha1, $ref_type) = (undef, undef);
59 }
60 2 my ($subject, $commitinfo) = split /\0/, $rest, 2;
61 2 my ($committer, $epoch, $tz) =
62 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
63 2 my $dt = DT->from_epoch(
64 epoch => $epoch,
65 time_zone => $tz,
66 );
67  
68 2 return $class->$orig(
69 sha1 => $sha1,
70 name => $name,
71 type => $type,
72 committer => $committer,
73 last_change => $dt,
74 ref_sha1 => $ref_sha1,
75 ref_type => $ref_type,
76 );
77 } else {
78 1 return $class->$orig(@_);
79 }
80 3 };
81  
82 4 ▶sub is_valid_tag {
Subroutine is_valid_tag: called CC=1 SCAR=0.0
Pod undocumented
83 4 local $_ = pop;
84 # Ignore tags like - http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec
85 4 return /^\S+ \S+ \S+ (?:\S+)? (?:\S+)?[^\0]+\0.*\s\d+\s+[+-]\d+$/;
86 }
87  
88 3 1;
« Gitalist/HasUtils.pm ↑ Summary Gitalist/Head.pm »