zestsoftware / zest.releaser

Python software releasing made easy and repeatable
https://zestreleaser.readthedocs.io
GNU General Public License v2.0
198 stars 62 forks source link

When CHANGES.rst and setup.py disagree about the next version number, pick the greater one? #339

Open mgedmin opened 4 years ago

mgedmin commented 4 years ago

I accidentally released zope.proxy 4.3.3 instead of 4.4.0 today because while the upcoming version in CHANGES.rst was correctly specified as 4.4.0, people forgot to update setup.py and it still said 4.3.3.dev0.

This is entirely my own fault for not paying attention, but I think zest.releaser could help prevent such accidents if it noticed that the version numbers were different and picked the higher one, or at least printed an extra warning.

mauritsvanrees commented 4 years ago

In prerelease.py after asking for the new version it seems we can do something like this:

# Be careful with AttributeErrors, KeyErrors.
last_released_version = self.data["headings"][0]["version"]
# Use some setuptools version parsing for the next line.
# If that fails, ignore the check.
if suggestion < last_released_version:
    print("Last version number X in history is greater than new version Y. "
             "Are you sure?")
    # if not: sys.exit(1)

Or before these lines, we can simply print the last history version, maybe only if it is higher than the version we get from the vcs.

I can see about that when I have some time. Or a PR is welcome.