--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use warnings FATAL => 'all';
+use File::Find;
+
+sub version_parts {
+ my @parts = split /\./, shift;
+ if (@parts == 2) {
+ my $dec = pop @parts;
+ push @parts, $dec =~ /(\d{1,3})/g;
+ }
+ $_ += 0 for @parts;
+ push @parts, 0
+ until @parts >= 3;
+ return @parts;
+}
+
+chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}'));
+
+my @parts = version_parts($LATEST);
+
+my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts);
+
+my %bump_part = (major => 0, minor => 1, bugfix => 2);
+
+my @new_parts = @parts;
+
+my $bump_this = $bump_part{$ARGV[0]||'bugfix'};
+
+if (defined $bump_this) {
+ $new_parts[$bump_this]++;
+ $new_parts[$_] = 0 for ($bump_this+1 .. $#new_parts);
+}
+elsif ($ARGV[0] =~ /^[0-9]+(?:\.[0-9]+)*$/) {
+ @new_parts = version_parts($ARGV[0]);
+}
+else {
+ die "no idea which part to bump - $ARGV[0] means nothing to me"
+}
+
+my $NEW_DECIMAL = sprintf('%i.%03i%03i', @new_parts);
+
+warn "Bumping $OLD_DECIMAL -> $NEW_DECIMAL\n";
+my $vstring = join('.', @parts);
+
+my %files;
+find({
+ no_chdir => 1,
+ wanted => sub {
+ return
+ unless -f && /\.pod$|\.pm$/;
+ my $file = $_;
+ open my $fh, '<', $file
+ or die "can't open $file: $!";
+ my $content = do { local $/; <$fh> };
+ close $fh;
+
+ $content =~ s{
+ ( \$VERSION \s* = \s* )
+ (['"]?) v?([.0-9]+) \2
+ (
+ \s*;
+ (?: \s*\#\s* )?
+ )
+ (v?[.0-9]+)?
+ }{
+ die "unable to bump version number in $file from $OLD_DECIMAL, found $3\n"
+ if $3 ne $OLD_DECIMAL && $3 ne $vstring;
+ $1 . "'" . $NEW_DECIMAL . "'" . $4 . (
+ $5 ? $vstring : ''
+ )
+ }xe
+ or return;
+
+ $files{$file} = $content;
+ },
+}, 'lib');
+
+for my $file (sort keys %files) {
+ warn " updating $file\n";
+ open my $fh, '>', $file
+ or die "can't open $file: $!";
+ print { $fh } $files{$file};
+ close $fh;
+}
sub dist_test {
my $self = shift;
- my $dist_test = $self->SUPER::dist_test(@_) . <<'END'
+ my $dist_test = $self->SUPER::dist_test(@_);
+
+ my $include = '';
+ if (open my $fh, '<', 'maint/Makefile.include') {
+ $include = "\n# --- Makefile.include:\n" . do { local $/; <$fh> };
+ }
+
+ $dist_test .= <<'END'
# --- Distar section:
preflight:
nextrelease:
$(ABSPERLRUN) Distar/helpers/add-changelog-heading $(VERSION) Changes
git add -p Changes
+END
+ for my $type ('', 'minor', 'major') {
+ if ($include !~ /^bump$type:/m) {
+ my $arg = $type || '$(V)';
+ $dist_test .= <<"END"
+bump$type:
+ Distar/helpers/bump-version $arg
+ rm Makefile
END
- if (open my $fh, '<', 'maint/Makefile.include') {
- $dist_test .= do { local $/; <$fh> };
+ }
}
+
+ $dist_test .= $include . "\n";
+
return $dist_test;
}
}