Skip to content

Commit

Permalink
[rebase] second stab at #86 part two: try using 'floor' style version…
Browse files Browse the repository at this point in the history
… objects instead of partial ones, plus related pseudo hacks. all unit tests pass but one
  • Loading branch information
bitprophet committed Jan 30, 2020
1 parent 812c8c7 commit cfa754e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion releases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 12 additions & 15 deletions releases/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down Expand Up @@ -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):
"""
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cfa754e

Please sign in to comment.