lib/App/gh/Command/Import.pm

filter: Statementstmt 48.9% 23 / 47 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 37.5% 30 / 80 CC 9 SCAR 38.7
CC
9
Cov
36%
run
90.0
options
2.0
BEGIN
1.0
CRAP 48.2
« lib/App/gh/Command/Pullreq/Show.pm ↑ Summary lib/App/gh/Config.pm »
1 package App::gh::Command::Import;
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(App::gh::Command);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use App::gh::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 require App::gh::Git;
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub options {
Subroutine options: not called CC=1 SCAR=6.9
Pod undocumented
12 0 'n|name=s' => 'name',
13 'd|description=s' => 'description',
14 'homepage=s' => 'homepage',
15 'p|private' => 'private',
16 'r|remote=s' => 'remote',
17 }
18  
19 0 ▶sub run {
Subroutine run: not called CC=9 SCAR=45.0
Pod undocumented
20 0 my ($self) = @_;
21 0 my $local_repo = App::gh->git;
22 0 ▶ my $remote = $self->{remote} || 'origin';
Condition0%0/2
$self->{'remote'} || 'origin'
l!l
00
MC/DC0%0/1
$self->{'remote'} || 'origin'
$self->{'remote'}
Truth table0%0/2
A
A= $self->{'remote'}
Aresult
11
00
23 0 my $config = App::gh->config->current;
24 0 my $basename = basename( $local_repo->wc_path() );
25 0 ▶ my $reponame = $self->{name} || $basename;
Condition0%0/3
$self->{'name'} || $basename
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'name'} || $basename
$self->{'name'} $basename
Truth table0%0/3
A || B
A= $self->{'name'}B= $basename
ABresult
1X1
011
000
26 0 my $gh_id = App::gh->config->github_id();
27  
28 # Check if remote already exists
29 0 ▶ if ($local_repo->config("remote.$remote.fetch")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local_repo->config("remote.$remote.fetch")) 0 0 0
30 0 croak "Remote [$remote] already exists. Try specifying another one using --remote.";
31 }
32  
33  
34 # Check if repo already exists
35 0 my $existing_gh_repo = eval { App::gh->github->repos->get( $gh_id, $reponame ) };
36 0 ▶ if ($existing_gh_repo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($existing_gh_repo) { } 0 0 0
37 # FIXME: Update existing repo
38 # my %args = (
39 # description => ($self->{description}
40 # || $existing_gh_repo->{description} || ""),
41 # homepage => ($self->{homepage}
42 # || $existing_gh_repo->{homepage} || "" ),
43 # # Don't change visibility of existing repo
44 # # public => $self->{private} ? 0 : 1 ,
45 # );
46 # my $ret = App::gh->api->repo_set_info( $gh_id, $reponame, %args );
47 # print "Repository updated: \n";
48 }
49 else {
50 # Create new repo
51 App::gh->github->repos->create({
52 # "org" => "perlchina", ## the organization
53 name => $reponame,
54 description => ($self->{description} || ""),
55 homepage => ($self->{homepage} || "" ),
56 0 ▶ public => $self->{private} ? 0 : 1 ,
Branch: 1 branch
BranchTrueFalseTotal
$self->{'private'} ? : 0 0 0
Condition0%0/4
$self->{'description'} || ''
l!l
00
$self->{'homepage'} || ''
l!l
00
MC/DC0%0/1
$self->{'description'} || ''
$self->{'description'}
MC/DC0%0/1
$self->{'homepage'} || ''
$self->{'homepage'}
Truth table0%0/2
A
A= $self->{'description'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'homepage'}
Aresult
11
00
57 });
58 0 info "Repository created. \n";
59 }
60  
61 0 info "Adding GitHub repo $reponame as remote [$remote].";
62 0 $local_repo->command("remote", "add", $remote,
63 "git\@github.com:${gh_id}/${reponame}.git");
64  
65 # Only set up branch remote if it isn't already set up.
66 0 ▶ if (! $local_repo->config('branch.master.remote')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($local_repo->config("branch.master.remote")) 0 0 0
67 0 info "Setting up remote [$remote] for master branch.";
68 0 $local_repo->command('config', 'branch.master.remote', "$remote");
69 0 $local_repo->command('config', 'branch.master.merge', 'refs/heads/master');
70 }
71  
72 0 info "Pushing to remote [$remote]";
73 0 $local_repo->command("push", $remote , "master");
74 0 info "Done.\n";
75 }
76  
77 1 1;
78 __END__
« lib/App/gh/Command/Pullreq/Show.pm ↑ Summary lib/App/gh/Config.pm »