utils/bump_version: Remove empty sections from CHANGES automatically

This commit is contained in:
Takeshi KOMIYA 2020-02-23 15:57:51 +09:00
parent 583667701e
commit d98b2f05a3
2 changed files with 4 additions and 5 deletions

View File

@ -114,7 +114,7 @@ class Changes:
f.truncate(0) f.truncate(0)
f.write(heading + '\n') f.write(heading + '\n')
f.write('=' * len(heading) + '\n') f.write('=' * len(heading) + '\n')
f.write(body) f.write(self.filter_empty_sections(body))
def add_release(self, version_info): def add_release(self, version_info):
if version_info[-2:] in (('beta', 0), ('final', 0)): if version_info[-2:] in (('beta', 0), ('final', 0)):
@ -142,6 +142,9 @@ class Changes:
f.write('\n') f.write('\n')
f.write(body) f.write(body)
def filter_empty_sections(self, body):
return re.sub('^\n.+\n-{3,}\n+(?=\n.+\n[-=]{3,}\n)', '', body, flags=re.M)
def parse_options(argv): def parse_options(argv):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()

View File

@ -8,7 +8,6 @@ for stable releases
* Run ``git fetch; git status`` and check nothing changed * Run ``git fetch; git status`` and check nothing changed
* ``python utils/bump_version.py X.Y.Z`` * ``python utils/bump_version.py X.Y.Z``
* Check diff by ``git diff`` * Check diff by ``git diff``
* Edit CHANGES if empty section exists
* ``git commit -am 'Bump to X.Y.Z final'`` * ``git commit -am 'Bump to X.Y.Z final'``
* ``make clean`` * ``make clean``
* ``python setup.py release bdist_wheel sdist`` * ``python setup.py release bdist_wheel sdist``
@ -36,7 +35,6 @@ for first beta releases
* Run ``(cd sphinx/locale; tx push -s)`` * Run ``(cd sphinx/locale; tx push -s)``
* ``python utils/bump_version.py X.Y.0b1`` * ``python utils/bump_version.py X.Y.0b1``
* Check diff by ``git diff`` * Check diff by ``git diff``
* Edit CHANGES if empty section exists
* ``git commit -am 'Bump to X.Y.0 beta1'`` * ``git commit -am 'Bump to X.Y.0 beta1'``
* ``make clean`` * ``make clean``
* ``python setup.py release bdist_wheel sdist`` * ``python setup.py release bdist_wheel sdist``
@ -67,7 +65,6 @@ for other beta releases
* Run ``git fetch; git status`` and check nothing changed * Run ``git fetch; git status`` and check nothing changed
* ``python utils/bump_version.py X.Y.0bN`` * ``python utils/bump_version.py X.Y.0bN``
* Check diff by ``git diff`` * Check diff by ``git diff``
* Edit CHANGES if empty section exists
* ``git commit -am 'Bump to X.Y.0 betaN'`` * ``git commit -am 'Bump to X.Y.0 betaN'``
* ``make clean`` * ``make clean``
* ``python setup.py release bdist_wheel sdist`` * ``python setup.py release bdist_wheel sdist``
@ -97,7 +94,6 @@ for major releases
* Run ``git commit -am 'Update message catalogs'`` * Run ``git commit -am 'Update message catalogs'``
* ``python utils/bump_version.py X.Y.0`` * ``python utils/bump_version.py X.Y.0``
* Check diff by ``git diff`` * Check diff by ``git diff``
* Edit CHANGES if empty section exists
* ``git commit -am 'Bump to X.Y.0 final'`` * ``git commit -am 'Bump to X.Y.0 final'``
* ``make clean`` * ``make clean``
* ``python setup.py release bdist_wheel sdist`` * ``python setup.py release bdist_wheel sdist``