| 1 | package App::githook::perltidy::install; | ||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | use App::githook::perltidy::install_CI | ||||||||||||||||||||||||||||
| 5 | 9 | ▶ | isa => 'App::githook::perltidy', | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | has => { | ||||||||||||||||||||||||||||
| 7 | absolute => {}, | ||||||||||||||||||||||||||||
| 8 | force => {}, | ||||||||||||||||||||||||||||
| 9 | 9 | }; | |||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 9 | our $VERSION = '1.0.1'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 16 | 6 | my $pre_commit = $self->pre_commit; | |||||||||||||||||||||||||||
| 17 | 6 | ▶ | if ( -e $pre_commit or -l $pre_commit ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-e $pre_commit or -l $pre_commit
MC/DC50%1/2
-e $pre_commit or -l $pre_commit
-e $pre_commit
-l $pre_commit
Truth table66%2/3
A or B
A= -e $pre_commitB= -l $pre_commit
| |||||||||||||||||||||||||||||
| 18 | 5 | my $loc = $pre_commit->relative( $self->repo ); | |||||||||||||||||||||||||||
| 19 | 5 | ▶ | die "githook-perltidy: path already exists: $loc\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | . " (use --force to overwrite)\n" | ||||||||||||||||||||||||||||
| 21 | unless $self->force; | ||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 5 | my $gp = path($0); | |||||||||||||||||||||||||||
| 25 | 5 | ▶ | if ( $self->absolute ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 2 | $gp = $gp->realpath; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||||||||||
| 29 | 3 | $gp = $gp->basename; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 5 | $pre_commit->parent->mkpath; | |||||||||||||||||||||||||||
| 33 | 5 | $pre_commit->spew( | |||||||||||||||||||||||||||
| 34 | qq{#!/bin/sh | ||||||||||||||||||||||||||||
| 35 | if [ "\$NO_GITHOOK_PERLTIDY" != "1" ]; then | ||||||||||||||||||||||||||||
| 36 | PERL5LIB="" $gp pre-commit | ||||||||||||||||||||||||||||
| 37 | fi | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | 5 | ▶ | chmod 0755, $pre_commit || warn "chmod: $!"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pre_commit || warn("chmod: $!")
MC/DC0%0/1
$pre_commit || warn("chmod: $!")
$pre_commit
Truth table50%1/2
A
A= $pre_commit
| |||||||||||||||||||||||||||||
| 41 | 5 | print $pre_commit; | |||||||||||||||||||||||||||
| 42 | 5 | ▶ | print " (forced)" if $self->force; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 5 | ▶ | print " (absolute)" if $self->absolute; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 5 | print "\n"; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 9 | 1; | |||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||