From cfa754e3c69469267608c76960dfb373348909c4 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Wed, 29 Jan 2020 20:06:51 -0500 Subject: [PATCH] [rebase] second stab at #86 part two: try using 'floor' style version objects instead of partial ones, plus related pseudo hacks. all unit tests pass but one --- releases/__init__.py | 2 +- releases/models.py | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/releases/__init__.py b/releases/__init__.py index 5a9bf33..57ac907 100644 --- a/releases/__init__.py +++ b/releases/__init__.py @@ -432,7 +432,7 @@ def handle_upcoming_major_release(entries, manager): # to the line manager! for obj in next_releases: # TODO: update when Release gets tied closer w/ Version - version = Version(obj.number) + version = Version(obj.full_number) if version.minor == 0 and version.patch == 0: manager.add_family(obj.family) diff --git a/releases/models.py b/releases/models.py index 38ec780..b6e6247 100644 --- a/releases/models.py +++ b/releases/models.py @@ -2,19 +2,10 @@ from operator import xor from docutils import nodes -from semantic_version import Version as SimpleVersion, SimpleSpec +from semantic_version import Version, SimpleSpec import six -class Version(StrictVersion): - """ - Version subclass toggling ``partial=True`` by default. - """ - - def __init__(self, version_string, partial=True): - super(Version, self).__init__(version_string, partial) - - # Issue type list (keys) + color values ISSUE_TYPES = {"bug": "A04040", "feature": "40A056", "support": "4070A0"} @@ -120,7 +111,7 @@ def default_spec(self, manager): buckets = self.minor_releases(manager) if buckets: specstr = ">={}".format(max(buckets)) - return SimpleSpec(specstr) if specstr else SimpleSpec() + return SimpleSpec(specstr) if specstr else SimpleSpec("*") def add_to_manager(self, manager): """ @@ -131,20 +122,20 @@ def add_to_manager(self, manager): # Only look in appropriate major version/family; if self is an issue # declared as living in e.g. >=2, this means we don't even bother # looking in the 1.x family. - families = [Version(str(x)) for x in manager] - versions = list(spec.filter(families)) + majors = [Version("{}.0.0".format(x)) for x in manager] + versions = list(spec.filter(majors)) for version in versions: family = version.major # Within each family, we further limit which bugfix lines match up # to what self cares about (ignoring 'unreleased' until later) candidates = [ - Version(x) + Version("{}.0".format(x)) for x in manager[family] if not x.startswith("unreleased") ] # Select matching release lines (& stringify) buckets = [] - bugfix_buckets = [str(x) for x in spec.filter(candidates)] + bugfix_buckets = ["{0.major}.{0.minor}".format(x) for x in spec.filter(candidates)] # Add back in unreleased_* as appropriate # TODO: probably leverage Issue subclasses for this eventually? if self.is_buglike: @@ -187,6 +178,12 @@ class Release(nodes.Element): def number(self): return self["number"] + @property + def full_number(self): + if len(self.number.split(".")) == 3 or self.number.endswith("0"): + return self.number + return "{}.0".format(self.number) + @property def minor(self): # TODO: use Version