GitGot/Command/clone.pm

filter: Statementstmt 89.0% 49 / 55 Branchbran 40.0% 4 / 10 Conditioncond 35.7% 5 / 14 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 1 totaltotal 72.1% 70 / 97 CC 10 SCAR 22.8
CC
10
Cov
73%
_execute
19.5
BEGIN
1.0
BEGIN
1.0
CRAP 9.8
« GitGot/Command/fork.pm ↑ Summary GitGot/Command/list.pm »
1 package App::GitGot::Command::clone;
2 16 our $AUTHORITY = 'cpan:GENEHACK';
3 16 $App::GitGot::Command::clone::VERSION = '1.339';
4 # ABSTRACT: clone a remote repo and add it to your config
5 16 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use IO::Prompt::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 16 ▶use App::GitGot -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use App::GitGot::Repo::Git;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 extends 'App::GitGot::Command';
17 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 ▶sub options {
Subroutine options: called CC=1 SCAR=0.0
Pod undocumented
20 2 my( $class , $app ) = @_;
21 return (
22 2 [ 'defaults|D' => 'use the default choices for all prompts' ] ,
23 [ 'recursive|r' => 'clone submodules recursively' => { default => 0 } ],
24 );
25 }
26  
27 2 ▶sub _use_io_page { 0 }
Subroutine _use_io_page: called CC=1 SCAR=0.0
28  
29 2 ▶sub _execute {
Subroutine _execute: called CC=10 SCAR=29.7
30 2 my ( $self, $opt, $args ) = @_;
31  
32 2 my ( $repo , $path ) = @$args;
33  
34 2 ▶ $repo // ( say STDERR 'ERROR: Need the URL to clone!' and exit(1) );
Condition50%3/6
$repo // say(STDERR "ERROR: Need the URL to clone!") && exit 1
l!l&&r!l&&!r
110
say STDERR "ERROR: Need the URL to clone!" and exit 1
!ll
010
MC/DC0%0/2
$repo // say(STDERR "ERROR: Need the URL to clone!") && exit 1
$repo say STDERR "ERROR: Need the URL to clone!"
Truth table66%2/3
A // B
A= $repoB= say STDERR "ERROR: Need the URL to clone!"
ABresult
1X1
011
000
35  
36 1 ▶ my $cwd = getcwd
Branch: 1 branch
BranchTrueFalseTotal
my $cwd = getcwd() or say STDERR "ERROR: Couldn't determine path" and exit 1 1 0 1
Condition16%1/6
(my $cwd = getcwd()) || say(STDERR q[ERROR: Couldn't determine path]) && exit 1
l!l&&r!l&&!r
100
say STDERR "ERROR: Couldn't determine path" and exit 1
!ll
000
MC/DC0%0/2
(my $cwd = getcwd()) || say(STDERR q[ERROR: Couldn't determine path]) && exit 1
(my $cwd = getcwd()) say STDERR "ERROR: Couldn't determine path"
Truth table33%1/3
A || B
A= (my $cwd = getcwd())B= say STDERR "ERROR: Couldn't determine path"
ABresult
1X1
011
000
37 or( say STDERR "ERROR: Couldn't determine path" and exit(1) );
38  
39 1 my $name = path( $repo )->basename;
40 1 $name =~ s/.git$//;
41  
42 1 ▶ $path //= "$cwd/$name";
Condition50%1/2
$path //= "$cwd/$name"
l!l
01
MC/DC0%0/1
$path //= "$cwd/$name"
$path
Truth table50%1/2
A
A= $path
Aresult
11
00
43 1 $path = path( $path )->absolute;
44  
45 1 my $tags;
46  
47 1 ▶ unless ( $self->opt->defaults ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->opt->defaults) 0 1 1
48 0 $name = prompt( 'Name: ' , $name );
49 0 while() {
50 0 $path = prompt( 'Path: ' , $path );
51 0 ▶ last if not path($path)->exists;
Branch: 1 branch
BranchTrueFalseTotal
unless path($path)->exists 0 0 0
52 0 say "can't clone into '$path': directory already exists";
53 }
54 0 $tags = prompt( 'Tags: ' , $tags );
55 }
56  
57 1 my $new_entry = App::GitGot::Repo::Git->new({ entry => {
58 repo => $repo,
59 name => $name,
60 type => 'git',
61 path => $path,
62 }});
63 1 ▶ $new_entry->{tags} = $tags if $tags;
Branch: 1 branch
BranchTrueFalseTotal
if $tags 0 1 1
64  
65 1 ▶ say "Cloning into '$path'..." unless $self->quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->quiet 0 1 1
66 1 $new_entry->clone(
67 { recursive => $self->opt->recursive },
68 $repo , $path
69 );
70  
71 1 $self->add_repo( $new_entry );
72 1 $self->write_config;
73 }
74  
75 16 1;
76  
77 __END__
« GitGot/Command/fork.pm ↑ Summary GitGot/Command/list.pm »