diff options
author | Tatsuhiko Miyagawa <miyagawa@bulknews.net> | 2013-06-05 19:10:28 +0900 |
---|---|---|
committer | Tatsuhiko Miyagawa <miyagawa@bulknews.net> | 2013-06-05 19:10:28 +0900 |
commit | 453642d603522bee0e9fb5fbcc0b4f4fb79d6a5d (patch) | |
tree | 4c4f18d95b28f09721b3ec28c4c188b226595380 | |
parent | 26f9ea0b7610219a3cf9c024e95712b507d31353 (diff) | |
download | carton-453642d603522bee0e9fb5fbcc0b4f4fb79d6a5d.tar.gz |
Honor newer versions of install if there are multiples that both satisfy cpanfile requirements
-rw-r--r-- | lib/Carton/Lock.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Carton/Lock.pm b/lib/Carton/Lock.pm index e243367..cb83025 100644 --- a/lib/Carton/Lock.pm +++ b/lib/Carton/Lock.pm @@ -127,7 +127,17 @@ sub find_installs { my $module = Carton::Util::load_json($file->[0]); my $mymeta = -f $file->[1] ? CPAN::Meta->load_file($file->[1])->as_struct({ version => "2" }) : {}; if ($reqs->accepts_module($module->{name}, $module->{provides}{$module->{name}}{version})) { - $installs{ $module->{name} } = { %$module, mymeta => $mymeta }; + if (my $exist = $installs{$module->{name}}) { + my $old_ver = version->new($exist->{provides}{$module->{name}}{version}); + my $new_ver = version->new($module->{provides}{$module->{name}}{version}); + if ($new_ver >= $old_ver) { + $installs{ $module->{name} } = { %$module, mymeta => $mymeta }; + } else { + # Ignore same distributions older than the one we have + } + } else { + $installs{ $module->{name} } = { %$module, mymeta => $mymeta }; + } } else { # Ignore installs because cpanfile doesn't accept it } |