blib/lib/Module/Install/Repository.pm

filter: Statementstmt 25.0% 13 / 52 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 1 totaltotal 16.1% 17 / 105 CC 23 SCAR 58.2
CC
23
Cov
14%
_find_repo
462.0
auto_set_repository
12.0
_execute
2.0
CRAP 336.0
↑ Summary
1 package Module::Install::Repository;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.08';
7  
8 1 ▶use base qw(Module::Install::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub _execute {
Subroutine _execute: not called CC=1 SCAR=6.9
11 0 my ($command) = @_;
12 0 `$command`;
13 }
14  
15 0 ▶sub auto_set_repository {
Subroutine auto_set_repository: not called CC=3 SCAR=24.8
Pod undocumented
16 0 my $self = shift;
17  
18 0 ▶ return unless $Module::Install::AUTHOR;
Branch: 1 branch
BranchTrueFalseTotal
unless $Module::Install::AUTHOR 0 0 0
19  
20 0 my $repo = _find_repo(\&_execute);
21 0 ▶ if ($repo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($repo) { } 0 0 0
22 0 $self->repository($repo);
23 } else {
24 0 warn "Cannot determine repository URL\n";
25 }
26 }
27  
28 0 ▶sub _find_repo {
Subroutine _find_repo: not called CC=21 SCAR=61.4
29 0 my ($execute) = @_;
30  
31 0 ▶ if (-e ".git") {
Branch: 5 branches
BranchTrueFalseTotal
if (-e '.git') { } 0 0 0
elsif (-e '.svn') { } 0 0 0
elsif (-e '_darcs') { } 0 0 0
elsif (-e '.hg') { } 0 0 0
elsif (-e "$ENV{'HOME'}/.svk") { } 0 0 0
32 0 foreach my $name (qw(origin github)) {
33 0 my $git_output = $execute->("git remote show -n $name");
34 0 ▶ if ($git_output =~ /Tracked remote branch/ && $git_output =~ /URL: (.*)$/m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($git_output =~ /Tracked remote branch/ and $git_output =~ /URL: (.*)$/m) 0 0 0
Condition0%0/3
$git_output =~ /Tracked remote branch/ and $git_output =~ /URL: (.*)$/m
!ll&&!rl&&r
000
MC/DC0%0/2
$git_output =~ /Tracked remote branch/ and $git_output =~ /URL: (.*)$/m
$git_output =~ /Tracked remote branch/ $git_output =~ /URL: (.*)$/m
Truth table0%0/3
A and B
A= $git_output =~ /Tracked remote branch/B= $git_output =~ /URL: (.*)$/m
ABresult
0X0
100
111
35 # XXX Make it public clone URL, but this only works with github
36 0 my $git_url = $1;
37 0 $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
38 0 return $git_url;
39 }
40 }
41  
42 0 ▶ if ($execute->('git svn info') =~ /URL: (.*)$/m) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$execute("git svn info") =~ /URL: (.*)$/m) 0 0 0
43 0 return $1;
44 }
45 } elsif (-e ".svn") {
46 0 ▶ if (`svn info` =~ /URL: (.*)$/m) {
Branch: 1 branch
BranchTrueFalseTotal
if (`svn info` =~ /URL: (.*)$/m) 0 0 0
47 0 return $1;
48 }
49 } elsif (-e "_darcs") {
50 # defaultrepo is better, but that is more likely to be ssh, not http
51 0 ▶ if (my $query_repo = `darcs query repo`) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $query_repo = `darcs query repo`) 0 0 0
52 0 ▶ if ($query_repo =~ m!Default Remote: (http://.+)!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_repo =~ m[Default Remote: (http://.+)]) 0 0 0
53 0 return $1;
54 }
55 }
56  
57 0 ▶ open my $handle, '<', '_darcs/prefs/repos' or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $handle, "<", "_darcs/prefs/repos" or return 0 0 0
58 0 ▶ while (<$handle>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $handle)) 0 0 0
59 0 chomp;
60 0 ▶ return $_ if m!^http://!;
Branch: 1 branch
BranchTrueFalseTotal
if m[^http://] 0 0 0
61 }
62 } elsif (-e ".hg") {
63 0 ▶ if ($execute->('hg paths') =~ /default = (.*)$/m) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$execute("hg paths") =~ /default = (.*)$/m) 0 0 0
64 0 my $mercurial_url = $1;
65 0 $mercurial_url =~ s!^ssh://hg\@(bitbucket\.org/)!https://$1!;
66 0 return $mercurial_url;
67 }
68 } elsif (-e "$ENV{HOME}/.svk") {
69 # Is there an explicit way to check if it's an svk checkout?
70 0 ▶ my $svk_info = `svk info` or return;
Branch: 1 branch
BranchTrueFalseTotal
my $svk_info = `svk info` or return 0 0 0
71 SVK_INFO: {
72 0 ▶ if ($svk_info =~ /Mirrored From: (.*), Rev\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($svk_info =~ /Mirrored From: (.*), Rev\./) 0 0 0
73 0 return $1;
74 }
75  
76 0 ▶ if ($svk_info =~ m!Merged From: (/mirror/.*), Rev\.!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($svk_info =~ m[Merged From: (/mirror/.*), Rev\.]) 0 0 0
77 0 ▶ $svk_info = `svk info /$1` or return;
Branch: 1 branch
BranchTrueFalseTotal
$svk_info = `svk info /$1` or return 0 0 0
78 0 redo SVK_INFO;
79 }
80 }
81  
82 0 return;
83 }
84 }
85  
86 1 1;
87 __END__
↑ Summary