Dist-Zilla-Plugin-Repository
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/Repository.pm view on Meta::CPAN
$uri =~ s![\w\-]+\@([^:]+):!git://$1/!;
return if $uri !~ m#^\w+://#;
my %repo = (type => 'git');
$uri = URI->new($uri);
$repo{web} = "https://" . $uri->host . $uri->path =~ s/\.git$//r;
$repo{url} = "$uri";
if ($self->github_http) {
# I prefer https://github.com/user/repository
# to git://github.com/user/repository.git
delete $repo{url};
$self->log(
"github_http is deprecated. " . "Consider using META.json instead,\n" . "which can store URLs for both git clone " . "and the web front-end.");
}
return %repo;
}
# Copy-Paste of Module-Install-Repository, thank MIYAGAWA
sub _find_repo {
my ($self, $execute) = @_;
my %repo;
if (-e ".git") {
if ($self->has_repository) {
%repo = $self->_git_to_repo($self->repository);
} elsif (my $url = $execute->('git config --get remote.' . $self->git_remote . '.url')) {
%repo = $self->_git_to_repo($url);
} elsif ($execute->('git svn info') =~ /URL: (.*)$/m) {
%repo = (qw(type svn url), $1);
}
# invalid github remote might come back with just the remote name
if ($repo{url} && $repo{url} =~ /\A\w+\z/) {
delete $repo{$_} for qw/url type web/;
$self->log("Skipping invalid git remote " . $self->git_remote);
}
} elsif (-e ".svn") {
$repo{type} = 'svn';
if ($execute->('svn info') =~ /URL: (.*)$/m) {
my $svn_url = $1;
if ($svn_url =~ /^https(\:\/\/.*?\.googlecode\.com\/svn\/.*)$/) {
$svn_url = 'http' . $1;
}
$repo{url} = $svn_url;
}
} elsif (-e "_darcs") {
# defaultrepo is better, but that is more likely to be ssh, not http
$repo{type} = 'darcs';
if (my $query_repo = $execute->('darcs query repo')) {
if ($query_repo =~ m!Default Remote: (http://.+)!) {
return %repo, url => $1;
}
}
open my $handle, '<', '_darcs/prefs/repos' or return;
while (<$handle>) {
chomp;
return %repo, url => $_ if m!^http://!;
}
} elsif (-e ".hg") {
$repo{type} = 'hg';
if ($execute->('hg paths') =~ /default = (.*)$/m) {
my $mercurial_url = $1;
$mercurial_url =~ s!^ssh://hg\@(bitbucket\.org/)!https://$1!;
$repo{url} = $mercurial_url;
}
} elsif (-e "$ENV{HOME}/.svk") {
# Is there an explicit way to check if it's an svk checkout?
my $svk_info = $execute->('svk info') or return;
SVK_INFO: {
if ($svk_info =~ /Mirrored From: (.*), Rev\./) {
return qw(type svn url) => $1;
}
if ($svk_info =~ m!Merged From: (/mirror/.*), Rev\.!) {
$svk_info = $execute->("svk info /$1") or return;
redo SVK_INFO;
}
}
}
if (!exists $repo{url} && $self->has_repository) {
$repo{url} = $self->repository;
}
return %repo;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::Repository - Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla
=head1 VERSION
version 0.25
=head1 SYNOPSIS
# dist.ini
[Repository]
=head1 DESCRIPTION
( run in 1.491 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )