Skip to content

Commit

Permalink
Check distvname is defined before comparing it
Browse files Browse the repository at this point in the history
to avoid several warnings every time the script is run.
Some weird uploads don't have it.

Also add some comments to make it easier to follow.
  • Loading branch information
rwstauner committed Aug 4, 2014
1 parent 5287be7 commit e40dd76
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/MetaCPAN/Script/Latest.pm
Expand Up @@ -100,12 +100,24 @@ sub run {
= ref $data->{'module.name'}
? @{ $data->{'module.name'} }
: $data->{'module.name'};

# Convert module name into Parse::CPAN::Packages::Fast::Package object.
@modules = grep {defined} map {
eval { $p->package($_) }
} @modules;

foreach my $module (@modules) {

# Get P:C:P:F:Distribution (CPAN::DistnameInfo) object for package.
my $dist = $module->distribution;
if ( $dist->distvname eq $data->{release}

# If this version of the module is the one listed in 02packages...

# NOTE: CPAN::DistnameInfo doesn't parse some weird uploads
# (like /\.pm\.gz$/) so distvname might not be present.
# I assume cpanid always will be.
if ( defined( $dist->distvname )
&& $dist->distvname eq $data->{release}
&& $dist->cpanid eq $data->{author} )
{
my $upgrade = $upgrade{ $data->{distribution} };
Expand Down

0 comments on commit e40dd76

Please sign in to comment.