[svn:ExtUtils-CBuilder] r12971 - ExtUtils-CBuilder/trunk/devtools

[email protected]
Newsgroups perl.module.build.checkins
Message-ID <[email protected]>
Author: dagolden
Date: Mon Jun 29 17:11:55 2009
New Revision: 12971

Modified:
   ExtUtils-CBuilder/trunk/devtools/bump_version.pl

Log:
let bump_version.pl prompt to rebump unreleased instead of dying

Modified: ExtUtils-CBuilder/trunk/devtools/bump_version.pl
==============================================================================
--- ExtUtils-CBuilder/trunk/devtools/bump_version.pl	(original)
+++ ExtUtils-CBuilder/trunk/devtools/bump_version.pl	Mon Jun 29 17:11:55 2009
@@ -35,7 +35,7 @@
 }
 
 die "must bump forward! ($version < $current)\n"
-  unless($version >= $current);
+  unless(eval $version >= eval $current);
 
 # NEVER BUMP THESE $VERSION numbers
 my @excluded = qw(
@@ -61,19 +61,34 @@
   my @head;
   while(@lines) {
     my $line = shift(@lines);
-    if($line =~ m/^$current - \w/) {
-      warn "Updating '$file'\n";
-      open(my $ofh, '>', $file) or die "cannot write '$file' $!";
-      print $ofh @head, "$version - \n", "\n", $line, @lines;
-      close($ofh) or die "cannot write '$file' $!";
-      return;
-    }
-    elsif($line =~ m/^$version(?: *- *)?$/) {
-      # TODO should just be checking for a general number+eol case?
-      die "$file probably needs to be reverted!";
-    }
-    elsif($line =~ m/^$current(?: *- *)?$/) {
-      die "Error parsing $file - found unreleased '$current'"; 
+    if($line =~ m/^$current/ ) {
+      # unreleased case -- re-bumping
+      if($line =~ m/^$current(?: *- *)?$/) {
+        print "Error parsing $file - found unreleased '$current'\n"; 
+        local $| = 1;
+        print "Are you sure you want to change the version number (y/n)? [n]:";
+        chomp(my $ans = <STDIN>);
+        if ( $ans !~ /^y/i ) {
+          print "Aborting!\n";
+          exit 1;
+        }
+        warn "Updating '$file'\n";
+        open(my $ofh, '>', $file) or die "cannot write '$file' $!";
+        print $ofh @head, "$version - \n", @lines;
+        close($ofh) or die "cannot write '$file' $!";
+        return;
+      }
+      if($line =~ m/^$current - \w/) {
+        warn "Updating '$file'\n";
+        open(my $ofh, '>', $file) or die "cannot write '$file' $!";
+        print $ofh @head, "$version - \n", "\n", $line, @lines;
+        close($ofh) or die "cannot write '$file' $!";
+        return;
+      }
+      elsif($line =~ m/^$version(?: *- *)?$/) {
+        # TODO should just be checking for a general number+eol case?
+        die "$file probably needs to be reverted!";
+      }
     }
     else {
       push(@head, $line);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.