summaryrefslogtreecommitdiff
path: root/script/test/versions.py
diff options
context:
space:
mode:
Diffstat (limited to 'script/test/versions.py')
-rwxr-xr-xscript/test/versions.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/script/test/versions.py b/script/test/versions.py
index f699f268..a06c49f2 100755
--- a/script/test/versions.py
+++ b/script/test/versions.py
@@ -36,23 +36,24 @@ import requests
GITHUB_API = 'https://api.github.com/repos'
+STAGES = ['tp', 'beta', 'rc']
-class Version(namedtuple('_Version', 'major minor patch rc edition')):
+
+class Version(namedtuple('_Version', 'major minor patch stage edition')):
@classmethod
def parse(cls, version):
edition = None
version = version.lstrip('v')
- version, _, rc = version.partition('-')
- if rc:
- if 'rc' not in rc:
- edition = rc
- rc = None
- elif '-' in rc:
- edition, rc = rc.split('-')
-
+ version, _, stage = version.partition('-')
+ if stage:
+ if not any(marker in stage for marker in STAGES):
+ edition = stage
+ stage = None
+ elif '-' in stage:
+ edition, stage = stage.split('-')
major, minor, patch = version.split('.', 3)
- return cls(major, minor, patch, rc, edition)
+ return cls(major, minor, patch, stage, edition)
@property
def major_minor(self):
@@ -63,14 +64,22 @@ class Version(namedtuple('_Version', 'major minor patch rc edition')):
"""Return a representation that allows this object to be sorted
correctly with the default comparator.
"""
- # rc releases should appear before official releases
- rc = (0, self.rc) if self.rc else (1, )
- return (int(self.major), int(self.minor), int(self.patch)) + rc
+ # non-GA releases should appear before GA releases
+ # Order: tp -> beta -> rc -> GA
+ if self.stage:
+ for st in STAGES:
+ if st in self.stage:
+ stage = (STAGES.index(st), self.stage)
+ break
+ else:
+ stage = (len(STAGES),)
+
+ return (int(self.major), int(self.minor), int(self.patch)) + stage
def __str__(self):
- rc = '-{}'.format(self.rc) if self.rc else ''
+ stage = '-{}'.format(self.stage) if self.stage else ''
edition = '-{}'.format(self.edition) if self.edition else ''
- return '.'.join(map(str, self[:3])) + edition + rc
+ return '.'.join(map(str, self[:3])) + edition + stage
BLACKLIST = [ # List of versions known to be broken and should not be used
@@ -113,9 +122,9 @@ def get_latest_versions(versions, num=1):
def get_default(versions):
- """Return a :class:`Version` for the latest non-rc version."""
+ """Return a :class:`Version` for the latest GA version."""
for version in versions:
- if not version.rc:
+ if not version.stage:
return version
@@ -123,8 +132,9 @@ def get_versions(tags):
for tag in tags:
try:
v = Version.parse(tag['name'])
- if v not in BLACKLIST:
- yield v
+ if v in BLACKLIST:
+ continue
+ yield v
except ValueError:
print("Skipping invalid tag: {name}".format(**tag), file=sys.stderr)