Bug 1453274 - Make ModernMozillaVersion support ESR r=bhearsum draft
authorJohan Lorenzo <jlorenzo@mozilla.com>
Fri, 20 Apr 2018 11:02:29 +0200
changeset 785520 97b8fcc613b60fa0971e8f7010ff741ea9fb5b03
parent 784946 8ed49dd81059dfdd876cf62ad5def1cfa56ffbbf
push id107243
push userbmo:jlorenzo@mozilla.com
push dateFri, 20 Apr 2018 09:14:32 +0000
reviewersbhearsum
bugs1453274
milestone61.0a1
Bug 1453274 - Make ModernMozillaVersion support ESR r=bhearsum MozReview-Commit-ID: LKs32b67GFL
python/mozrelease/mozrelease/versions.py
--- a/python/mozrelease/mozrelease/versions.py
+++ b/python/mozrelease/mozrelease/versions.py
@@ -3,19 +3,32 @@ from __future__ import absolute_import
 from distutils.version import StrictVersion
 import re
 
 
 class ModernMozillaVersion(StrictVersion):
     """A version class that is slightly less restrictive than StrictVersion.
        Instead of just allowing "a" or "b" as prerelease tags, it allows any
        alpha. This allows us to support the once-shipped "3.6.3plugin1" and
-       similar versions."""
-    version_re = re.compile(r"""^(\d+) \. (\d+) (\. (\d+))?
-                                ([a-zA-Z]+(\d+))?$""", re.VERBOSE)
+       similar versions.
+
+       It also defines Mozilla specific rules like:
+         * a beta has 2 digits only
+         * an ESR can have either 2 or 3
+         * a build number can exist at the end of the version.
+    """
+    # Inspired by https://github.com/mozilla-releng/ship-it/blob/\
+    # 18dc35c511c2d38a1f7472c34c435176f3807212/kickoff/views/forms.py#L221
+    version_re = re.compile(r"""^(\d+)\.(    # Major version number
+        (0)(a1|a2|b(\d+)|esr)?                   # 2-digit-versions (like 46.0, 46.0b1, 46.0esr)
+        |(                                       # Here begins the 3-digit-versions.
+            ([1-9]\d*)\.(\d+)|(\d+)\.([1-9]\d*)  # 46.0.0 is not correct
+        )(esr|([a-zA-Z]+(\d+)))?                 # Neither is 46.2.0b1, but we allow 3.6.3plugin1
+    )(build(\d+))?$""", re.VERBOSE)
+
 
 
 class AncientMozillaVersion(StrictVersion):
     """A version class that is slightly less restrictive than StrictVersion.
        Instead of just allowing "a" or "b" as prerelease tags, it allows any
        alpha. This allows us to support the once-shipped "3.6.3plugin1" and
        similar versions.
        It also supports versions w.x.y.z by transmuting to w.x.z, which