App-cpangitify
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/cpangitify.pm view on Meta::CPAN
{
_rm_rf($_) for $file->children;
}
$file->remove || die "unable to delete $file";
}
our $_run_cb = sub {};
our $original_run = \&Git::Wrapper::RUN;
our $trace = 0;
sub _run_wrapper ($self, @command)
{
my @display;
foreach my $arg (@command)
{
if(ref($arg) eq 'HASH')
{
foreach my $k (keys %$arg)
{
my $v = $arg->{$k};
push @display, "--$k";
push @display, $v =~ /\s/ ? "'$v'" : $v
if $v ne '1'; # yes there is a weird exception for this :P
}
}
else
{
push @display, $arg;
}
}
$_run_cb->($self, @display);
say "+ git @display" if $trace;
$original_run->($self, @command);
}
sub author ($cpanid)
{
state $cache = {};
unless(defined $cache->{$cpanid})
{
my $uri = URI->new($opt_metacpan_url . "v1/author/" . $cpanid);
my $res = $ua->get($uri);
unless($res->{success})
{
say "error fetching $uri";
say $res->{reason};
return 2;
}
$cache->{$cpanid} = decode_json($res->{content})
}
my $email = $cache->{$cpanid}->{email};
$email = $email->[0] if ref($email) eq 'ARRAY';
sprintf "%s <%s>", $cache->{$cpanid}->{name}, $email;
}
sub main ($, @args)
{
local @ARGV = @args;
no warnings 'redefine';
local *Git::Wrapper::RUN = \&_run_wrapper;
use warnings;
my %skip;
my $opt_backpan_index_url;
my $opt_backpan_url = "http://backpan.perl.org/authors/id";
$opt_metacpan_url = "http://fastapi.metacpan.org/";
my $opt_trace = 0;
my $opt_output;
my $opt_resume;
my $opt_branch = 'main';
GetOptions(
'backpan_index_url=s' => \$opt_backpan_index_url,
'backpan_url=s' => \$opt_backpan_url,
'metacpan_url=s' => \$opt_metacpan_url,
'trace' => \$opt_trace,
'skip=s' => sub ($version) { $skip{$_} = 1 for split /,/, $version },
'resume' => \$opt_resume,
'output|o=s' => \$opt_output,
'help|h' => sub { pod2usage({ -verbose => 2}) },
'branch|b=s' => \$opt_branch,
'version' => sub {
say 'cpangitify version ', ($App::cpangitify::VERSION // 'dev');
exit 1;
},
) || pod2usage(1);
local $trace = $opt_trace;
my @names = @ARGV;
s/::/-/g for @names;
my %names = map { $_ => 1 } @names;
my $name = $names[0];
pod2usage(1) unless $name;
my $dest = $opt_output ? dir($opt_output)->absolute : dir()->absolute->subdir($name);
if(-e $dest && ! $opt_resume)
{
say "already exists: $dest";
say "you may be able to update with the --resume option";
say "but any local changes to your repository will be overwritten by upstream";
return 2;
}
say "creating/updating index...";
my $history = CPAN::ReleaseHistory->new(
maybe url => $opt_backpan_index_url
)->release_iterator;
say "searching...";
my @rel;
while(my $release = $history->next_release)
{
next unless defined $release->distinfo->dist;
next unless $names{$release->distinfo->dist};
push @rel, $release;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 4.098 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )