[Rt-commit] rt branch, 4.0/expose-version-words, updated. rt-4.0.0-170-gad6a1a8

? sunnavy sunnavy at bestpractical.com
Mon May 2 13:49:52 EDT 2011


The branch, 4.0/expose-version-words has been updated
       via  ad6a1a8415c332671d68448c3db27046481178b9 (commit)
      from  3aaa892cbe08aa02abc2daa74bee13c3e64f117e (commit)

Summary of changes:
 lib/RT/Handle.pm          |    8 +++++++-
 sbin/rt-setup-database.in |    5 +++--
 2 files changed, 10 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit ad6a1a8415c332671d68448c3db27046481178b9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 3 01:34:32 2011 +0800

    expose verison words to do a more strict version check in rt-setup-database

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index f47729b..80d60cf 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -565,7 +565,13 @@ sub cmp_version($$) {
         return $a[$i] <=> $b[$i] if $a[$i] <=> $b[$i];
     }
     return 0;
-}}
+}
+
+sub version_words {
+    return keys %word;
+}
+
+}
 
 
 =head2 InsertInitialData
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index ff0b8d3..6b46086 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -298,6 +298,7 @@ sub action_upgrade {
     return (0, "Couldn't read dir '$base_dir' with upgrade data")
         unless -d $base_dir || -r _;
 
+    my $version_word_regex = join '|', RT::Handle->version_words;
     my $upgrading_from = undef;
     do {
         if ( defined $upgrading_from ) {
@@ -308,7 +309,7 @@ sub action_upgrade {
         $upgrading_from = scalar <STDIN>;
         chomp $upgrading_from;
         $upgrading_from =~ s/\s+//g;
-    } while $upgrading_from !~ /^\d+\.\d+\.\w+$/;
+    } while $upgrading_from !~ /^\d+\.\d+\.\d+(?:$version_word_regex)\d*$/;
 
     my $upgrading_to = $RT::VERSION;
     return (0, "The current version $upgrading_to is lower than $upgrading_from")
@@ -343,7 +344,7 @@ sub action_upgrade {
             chomp $custom_upgrading_to;
             $custom_upgrading_to =~ s/\s+//g;
             last unless $custom_upgrading_to;
-        } while $custom_upgrading_to !~ /^\d+\.\d+\.\w+$/;
+        } while $custom_upgrading_to !~ /^\d+\.\d+\.\d+(?:$version_word_regex)\d*$/;
 
         if ( $custom_upgrading_to ) {
             return (

-----------------------------------------------------------------------


More information about the Rt-commit mailing list