blib/lib/Dist/Inkt/Role/Git.pm

filter: Statementstmt 59.0% 26 / 44 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod n/a totaltotal 53.2% 33 / 62 CC 6 SCAR 21.2
CC
6
Cov
50%
__ANON__
20.0
__ANON__
12.0
_build_source_control_is_git
2.0
CRAP 8.3
↑ Summary
1 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Dist::Inkt::Role::Git;
6  
7 1 our $AUTHORITY = 'cpan:KJETILK';
8 1 our $VERSION = '0.001';
9  
10  
11 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Git::Sub qw(tag status log);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Types::Standard 'Bool';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 1 has source_control_is_git => (
17 is => "ro",
18 isa => Bool,
19 lazy => 1,
20 builder => "_build_source_control_is_git",
21 );
22
23 0 ▶sub _build_source_control_is_git {
Subroutine _build_source_control_is_git: not called CC=1 SCAR=6.9
24 0 my $self = shift;
25 0 !! $self->rootdir->child(".git")->is_dir;
26 }
27
28 0 ▶after BUILD => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
29 0 my $self = shift;
30 0 ▶ return unless $self->source_control_is_git;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->source_control_is_git 0 0 0
31 0 $self->log('Source control is git');
32  
33 0 my @uncommitted = git::status qw(--untracked-files=no --porcelain);
34 0 ▶ if (scalar @uncommitted) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @uncommitted) 0 0 0
35 0 $self->log("git has uncommitted changes in following files:");
36 0 foreach my $msg (@uncommitted) {
37 0 $self->log($msg);
38 }
39 0 die "Please commit them";
40 }
41  
42 1 };
43  
44  
45 0 ▶before BuildTarball => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
46 0 my $self = shift;
47 0 ▶ return unless $self->source_control_is_git;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->source_control_is_git 0 0 0
48 0 my $pstr = 'release-' . $self->version;
49 0 ▶ $pstr = 'dev-' . $pstr if ($self->version =~ m/_/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->version =~ /_/ 0 0 0
50 0 my $short = git::log qw(--pretty=format:'%h' -n 1);
51 0 $self->log("Tagging $short as $pstr.");
52 0 git::tag -s => -m => "Releasing $short tagged $pstr.", $pstr;
53 1 };
54  
55  
56 1 1;
57  
58 __END__
↑ Summary