| 1 | package Git::Gitalist::Util; | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Method::Signatures; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use File::Which; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Git::PurePerl; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use IPC::Run qw(run start); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Symbol qw(geniosym); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | 2 | has repository => ( | |||||||||||||||||||||||||||||||||||
| 14 | isa => 'Git::Gitalist::Repository', | ||||||||||||||||||||||||||||||||||||
| 15 | handles => { gitdir => 'path' }, | ||||||||||||||||||||||||||||||||||||
| 16 | is => 'bare', # No accessor | ||||||||||||||||||||||||||||||||||||
| 17 | weak_ref => 1, # Weak, you have to hold onto me. | ||||||||||||||||||||||||||||||||||||
| 18 | predicate => 'has_repository', | ||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||
| 21 | 2 | has _git => ( | |||||||||||||||||||||||||||||||||||
| 22 | isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 24 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | has gpp => ( | ||||||||||||||||||||||||||||||||||||
| 28 | isa => 'Git::PurePerl', is => 'ro', lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||
| 30 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | confess("Cannot get gpp without repository") | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 32 | unless $self->has_repository; | ||||||||||||||||||||||||||||||||||||
| 33 | 2 | Git::PurePerl->new(gitdir => $self->gitdir); | |||||||||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||||||||||
| 35 | 2 | ); | |||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | sub git_executable_path { | ||||||||||||||||||||||||||||||||||
|
Subroutine
git_executable_path: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 38 | 3 | return File::Which::which('git'); | |||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | method BUILDARGS(@p) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BUILDARGS: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||
| 42 | 3 | my $args = $self->SUPER::BUILDARGS(@p); | |||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | unless($args->{_git}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | $args->{_git} ||= git_executable_path | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args->{"_git"} ||= git_executable_path()
MC/DC0%0/2
$args->{"_git"} ||= git_executable_path()
$args->{"_git"}
git_executable_path()
Truth table33%1/3
A ||= B
A= $args->{"_git"}B= git_executable_path()
| |||||||||||||||||||||||||||||||||||||
| 46 | or die "Could not find a git executable in the PATH"; | ||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | 3 | return $args; | |||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | method run_cmd (@args) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
run_cmd: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||
| 53 | 19 | ▶ | unshift @args, ( '--git-dir' => $self->gitdir ) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 54 | if $self->has_repository; | ||||||||||||||||||||||||||||||||||||
| 55 | # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/; | ||||||||||||||||||||||||||||||||||||
| 56 | 19 | run [$self->_git, @args], \my($in, $out, $err); | |||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||
| 58 | 19 | return $out; | |||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | method run_cmd_fh (@args) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
run_cmd_fh: not called CC=3 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($in, $out, $err) = (geniosym, geniosym, geniosym); | |||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | unshift @args, ('--git-dir' => $self->gitdir) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 64 | if $self->has_repository; | ||||||||||||||||||||||||||||||||||||
| 65 | # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/; | ||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | start [$self->_git, @args], | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 67 | '<pipe', $in, | ||||||||||||||||||||||||||||||||||||
| 68 | '>pipe', $out, | ||||||||||||||||||||||||||||||||||||
| 69 | '2>pipe', $err | ||||||||||||||||||||||||||||||||||||
| 70 | or die "cmd returned *?"; | ||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $out; | |||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | method run_cmd_list (@args) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
run_cmd_list: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||
| 75 | 3 | my $cmdout = $self->run_cmd(@args); | |||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | return $cmdout ? split(/\n/, $cmdout) : (); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | method get_gpp_object (MooseX::Types::Common::String::NonEmptySimpleStr $sha1) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.3
Subroutine
get_gpp_object: called CC=6 SCAR=19.6
Branch: 3 branches
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} ||= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} ||= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"}
"Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"}B= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
| |||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | return $self->gpp->get_object($sha1) || undef; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->gpp->get_object($sha1) || undef
MC/DC0%0/1
$self->gpp->get_object($sha1) || undef
$self->gpp->get_object($sha1)
Truth table50%1/2
A
A= $self->gpp->get_object($sha1)
| |||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||
| 83 | 2 | 1; | |||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||||||||||