|
Packit |
90fbfc |
#!/usr/bin/perl
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
use CPAN::Changes;
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
use Getopt::Long qw(GetOptions);
|
|
Packit |
90fbfc |
use Pod::Usage qw(pod2usage);
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
GetOptions( \my %opt,
|
|
Packit |
90fbfc |
'next!',
|
|
Packit |
90fbfc |
'token:s',
|
|
Packit |
90fbfc |
'headers!',
|
|
Packit |
90fbfc |
'reverse',
|
|
Packit |
90fbfc |
'check',
|
|
Packit |
90fbfc |
'help',
|
|
Packit |
90fbfc |
) or pod2usage( -verbose => 2 );
|
|
Packit |
90fbfc |
pod2usage( -verbose => 2 ) if $opt{help};
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
$opt{token} ||= qr/\{\{\$NEXT\}\}/;
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
my $changelog = shift;
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
unless ( $changelog ) {
|
|
Packit |
90fbfc |
# try to guess it
|
|
Packit |
90fbfc |
opendir my $dir, '.';
|
|
Packit |
90fbfc |
my @files = grep { -f $_ and /^change/i } readdir $dir;
|
|
Packit |
90fbfc |
die "changelog not provided and couldn't be guessed\n"
|
|
Packit |
90fbfc |
unless @files == 1;
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
$changelog = shift @files;
|
|
Packit |
90fbfc |
warn "changelog not provided, guessing '$changelog'\n\n";
|
|
Packit |
90fbfc |
}
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
if ($opt{check}) {
|
|
Packit |
90fbfc |
require Test::CPAN::Changes;
|
|
Packit |
90fbfc |
require Test::More;
|
|
Packit |
90fbfc |
Test::CPAN::Changes::changes_file_ok();
|
|
Packit |
90fbfc |
exit;
|
|
Packit |
90fbfc |
}
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
my $changes = CPAN::Changes->load(
|
|
Packit |
90fbfc |
$changelog,
|
|
Packit |
90fbfc |
( next_token => $opt{token} ) x $opt{next},
|
|
Packit |
90fbfc |
);
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
if( $opt{headers} ) {
|
|
Packit |
90fbfc |
$_->clear_changes for $changes->releases;
|
|
Packit |
90fbfc |
}
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
print $changes->serialize(
|
|
Packit |
90fbfc |
reverse => $opt{reverse},
|
|
Packit |
90fbfc |
);
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
__END__
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head1 NAME
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
tidy_changelog - command-line tool for CPAN::Changes
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head1 SYNOPSIS
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
$ tidy_changelog Changelog
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head1 DESCRIPTION
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
Takes a changelog file, parse it using L<CPAN::Changes> and prints out
|
|
Packit |
90fbfc |
the resulting output. If a file is not given, the program will see if
|
|
Packit |
90fbfc |
there is one file in the current directory beginning by 'change'
|
|
Packit |
90fbfc |
(case-insensitive) and, if so, assume it to be the changelog.
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head1 ARGUMENTS
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --next
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
If provided, assumes that there is a placeholder
|
|
Packit |
90fbfc |
header for an upcoming next release. The placeholder token
|
|
Packit |
90fbfc |
is given via I<--token>.
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --token
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
Regular expression to use to detect the token for an upcoming
|
|
Packit |
90fbfc |
release if I<--next> is used. If not explicitly given, defaults
|
|
Packit |
90fbfc |
to C<\{\{\$NEXT\}\}>.
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --headers
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
If given, only print out the release header lines, without any of the
|
|
Packit |
90fbfc |
changes.
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --reverse
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
Prints the releases in reverse order (from the oldest to latest).
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --check
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
Only check if the changelog is formatted properly using the changes_file_ok
|
|
Packit |
90fbfc |
function of L<Test::CPAN::Changes>.
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
=head2 --help
|
|
Packit |
90fbfc |
|
|
Packit |
90fbfc |
This help
|
|
Packit |
90fbfc |
|