X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=helpers%2Fbump-version;h=651c4b9c159e9de61851ca9760e7dae3755110ac;hb=53e484327023bc65082f974df2f1581cac8765be;hp=b474e3fb0cb18ccdd51bc09c133f30b2b747445c;hpb=edb3d04463c68c1afcdce30bf70529daf17ae64e;p=p5sagit%2FDistar.git diff --git a/helpers/bump-version b/helpers/bump-version index b474e3f..651c4b9 100755 --- a/helpers/bump-version +++ b/helpers/bump-version @@ -57,7 +57,7 @@ else { no_chdir => 1, wanted => sub { my $fn = File::Spec->abs2rel($_, '.'); - if (-d && $fn !~ /^$dir_match$/) { + if (-d && $fn !~ /^$dir_match/) { $File::Find::prune = 1; return; } @@ -101,17 +101,32 @@ for my $file (sort keys %files) { my $file_diff = ''; my $re = $file eq 'Makefile.PL' ? $MAKE_RE : $FILE_RE; my @lines = split /\r?\n/, $content; + my $in_pod = ''; for my $ln (0 .. $#lines) { my $line = $lines[$ln]; - if ($lines[$ln] =~ $re) { + my $new_line; + if ($in_pod && $line =~ /^=cut$/) { + $in_pod = ''; + } + elsif ($line =~ /^=\w+/) { + $in_pod = $line; + } + elsif (!$in_pod && $line =~ $re) { die "unable to bump version number in $file from $old_version, found $3\n" if !$force && $3 ne $old_version; my $comment = ($5 ? $5 . $new_vstring : ''); - my $new_line = "$1'$new_decimal'$4$comment$6"; + $new_line = "$1'$new_decimal'$4$comment$6"; + } + elsif ($in_pod =~ /\bversion\b/i && $lines[$ln] =~ /^((?:version\s+)?)v?([0-9]+(?:[._][0-9]+)*)$/) { + die "unable to bump version number in $file from $old_version, found $2\n" + if !$force && $2 ne $old_version; + $new_line = "$1$new_decimal"; + } + if (defined $new_line) { $file_diff .= <<"END_DIFF"; @@ -@{[ $ln ]},3 +@{[ $ln ]},3 @@ $lines[$ln-1] --$lines[$ln] +-$line +$new_line $lines[$ln+1] END_DIFF @@ -188,6 +203,9 @@ sub bump_version { $parts[$bump_this]++; $_ += 0 for @parts; + if (grep $_ > 999, @parts[1 .. $#parts]) { + warn "$new_decimal has a version component greater than 999. It will be incompatible with some uses in perl.\n"; + } $new_decimal = $new_vstring = $v . join '.', @parts; } else { @@ -235,4 +253,3 @@ sub bump_version { } return ($new_decimal, $new_vstring); } -