| 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
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my $repo = _find_repo(\&_execute); | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($repo) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$git_output =~ /Tracked remote branch/ and $git_output =~ /URL: (.*)$/m
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 43 | 0 | return $1; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } elsif (-e ".svn") { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if (`svn info` =~ /URL: (.*)$/m) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($query_repo =~ m!Default Remote: (http://.+)!) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | return $1; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | open my $handle, '<', '_darcs/prefs/repos' or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | while (<$handle>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | chomp; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $_ if m!^http://!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } elsif (-e ".hg") { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($execute->('hg paths') =~ /default = (.*)$/m) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 71 | SVK_INFO: { | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($svk_info =~ /Mirrored From: (.*), Rev\./) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | return $1; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ($svk_info =~ m!Merged From: (/mirror/.*), Rev\.!) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $svk_info = `svk info /$1` or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | redo SVK_INFO; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | return; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||