use
5.005;
$VERSION
=
'0.06'
;
sub
_execute {
my
(
$command
) =
@_
;
`
$command
`;
}
sub
auto_set_repository {
my
$self
=
shift
;
return
unless
$Module::Install::AUTHOR
;
my
$repo
= _find_repo(\
&_execute
);
if
(
$repo
) {
$self
->repository(
$repo
);
}
else
{
warn
"Cannot determine repository URL\n"
;
}
}
sub
_find_repo {
my
(
$execute
) =
@_
;
if
(-e
".git"
) {
if
(
$execute
->(
'git remote show -n origin'
) =~ /URL: (.*)$/m) {
my
$git_url
= $1;
$git_url
=~ s![\w\-]+\@([^:]+):!git://$1/!;
return
$git_url
;
}
elsif
(
$execute
->(
'git svn info'
) =~ /URL: (.*)$/m) {
return
$1;
}
}
elsif
(-e
".svn"
) {
if
(`svn info` =~ /URL: (.*)$/m) {
return
$1;
}
}
elsif
(-e
"_darcs"
) {
if
(
my
$query_repo
= `darcs query repo`) {
if
(
$query_repo
=~ m!Default Remote: (http://.+)!) {
return
$1;
}
}
open
my
$handle
,
'<'
,
'_darcs/prefs/repos'
or
return
;
while
(<
$handle
>) {
chomp
;
}
}
elsif
(-e
".hg"
) {
if
(
$execute
->(
'hg paths'
) =~ /
default
= (.*)$/m) {
my
$mercurial_url
= $1;
return
$mercurial_url
;
}
}
elsif
(-e
"$ENV{HOME}/.svk"
) {
my
$svk_info
= `svk info` or
return
;
SVK_INFO: {
if
(
$svk_info
=~ /Mirrored From: (.*), Rev\./) {
return
$1;
}
if
(
$svk_info
=~ m!Merged From: (/mirror/.*), Rev\.!) {
$svk_info
= `svk info /$1` or
return
;
redo
SVK_INFO;
}
}
return
;
}
}
1;