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

Refuse to edit history header when it may be from already released version #314

Closed mauritsvanrees closed 5 years ago

mauritsvanrees commented 5 years ago

We look for "unreleased" in it. Give a warning when this happens. Fixes issue #311.

This is a more general fix than the one in PR #313 which is specific for bumpversion. But it seems good to do both.

The current one might possibly have negative side effects when people do not have 'unreleased' in their changelog, but say (release date to be determined). So it could be that this fixes some things and breaks something else. To counter this, we might just need support for an extra item in setup.cfg, unreleased-marker similar to the development-marker that we already have.

But it already fixes something in the tests: in postrelease.txt we call prerelease and until now this would change 1.0 (1972-12-25) into 1.3 (<today>). With the current PR, it keeps the header, and it would log a warning, though that is not visible in the tests.

reinout commented 5 years ago

You're right. If something else than "unreleased" is somehow used, this PR might break some existing behaviour.

Would it be an idea to do the check the other way around? Try to detect (xxxx-xx-xx)? Just a basic regex .*\(\d[4]\-\d[2]\-\d[2]\)-like?

You wouldn't have false positives this way.

mauritsvanrees commented 5 years ago

That could work, although you wouldn't catch the case where people would use a history line like 1.0 (February 20, 2019).

reinout commented 5 years ago

Using bumpversion is already a bit of a corner case. That is, I've used it only once myself :-)

Supporting "February 20, last year" would be like supporting the corner case of a corner case.

But raising a warning on "not released yet", that's a one-level corner case of regular usage.

mauritsvanrees commented 5 years ago

I regularly use bumpversion when doing Plone releases. Note that the other PR (#313) is specifically about bumpversion, but this one is also applicable to prerelease, as evidenced by the small change in the tests. I will try the regular expression.

mauritsvanrees commented 5 years ago

Fixed.

Test run with a test package for which I already prepared a release yesterday:

$ prerelease 
Run pyroma on the package before tagging? (Y/n)? n
Do you want to run check-manifest? (Y/n)? n
Changelog entries for version 1.24.14:

1.24.14 (2019-02-19)
--------------------

- Nothing changed yet.

1.24.13 (2018-03-10)
--------------------
Enter version [1.24.14]: 
WARNING: Changelog contains "- Nothing changed yet.". Are you sure you want to release? (y/N)? y
WARNING: Refused to edit history header, because it looks to be from an already released version with a date. Would have wanted to set this header: 1.24.14 (2019-02-20)
INFO: Set setup.py's version to '1.24.14'
INFO: Changed version from 1.24.14.dev0 to 1.24.14
INFO: History file CHANGES.rst updated.
INFO: The 'git diff':

diff --git a/setup.py b/setup.py
index 4096d10..62a3b10 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages

-version = '1.24.14.dev0'
+version = '1.24.14'

 setup(name='mauritstestpackage2',
       version=version,

OK to commit this (Y/n)? 
reinout commented 5 years ago

Releasen maar.

mauritsvanrees commented 5 years ago

6.17.0 released.