Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (41 sloc) 1.648 kb
name 'changes';
description 'Show changes when upgrading a module';
author 'Tatsuhiko Miyagawa, Tokurhiro Matsuno';
api_version 0.1;
# TODO Adds hooks to display this *before* installing modules (and prompt)
# TODO Adds --changes command
# TODO make it work with cpanfresh feed -- the new releases are not on CPAN
hook install_success => sub {
my $args = shift;
sub extract_changes {
my $args = shift;
my $dist = "$args->{meta}->{name}-$args->{local}";
return if !$args->{local} or $args->{reinstall};
eval { require Algorithm::Diff };
if ($@) { $args->{app}->chat("$@\n"); return }
# All I need here is PAUSE, but has some "Special
# Files" support so let's figure out from there ...
my $html = $args->{app}->get("$dist");
if ($html =~ m!<a href="(/src/[^"]+)">(Change.*)</a>!i) {
my($link, $file) = ($1, $2);
open my $fh, "<$file" or return;
my $new_changes = join '', <$fh>;
$args->{app}->chat("Found $file file. Fetching $link\n");
my $old_changes = $args->{app}->get("$link");
my $diff = Algorithm::Diff->new(
[ split /\n/, $old_changes ],
[ split /\n/, $new_changes ],
my $result;
while ($diff->Next()) {
next if $diff->Same();
$result .= "$_\n" for $diff->Items(2);
$args->{app}->diag("\n" . $result) if $result;
} else {
$args->{app}->chat("$dist doesn't seem to have Changes file.\n");
Jump to Line
Something went wrong with that request. Please try again.