Skip to content

Commit

Permalink
Add towncrier.check_changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 21, 2023
1 parent 4cd9613 commit 364b0b7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v7.21.0
=======

* Added ``towncrier.check_changes`` from ``setuptools``'
``finalize``.

v7.20.0
=======

Expand Down
24 changes: 21 additions & 3 deletions jaraco/develop/towncrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,36 @@ def _release_bump(file):
return _release_bumps[type_]


def news_fragments():
except_ = 'README.rst', '.gitignore'
path = pathlib.Path('newsfragments')
names = (file for file in path.iterdir() if file.name not in except_)
return names if path.exists() else ()


def release_kind():
"""
Determine which release to make based on the files in the
changelog.
"""
path = pathlib.Path('newsfragments')
fragments = path.iterdir() if path.exists() else ()
bumps = map(_release_bump, fragments)
bumps = map(_release_bump, news_fragments())
# use min here as 'major' < 'minor' < 'patch'
return min(bumps, default='patch')


def check_changes():
"""
Verify that all of the news fragments have the appropriate names.
"""
unrecognized = [
str(file)
for file in news_fragments()
if not any(f".{key}" in file.suffixes for key in _release_bumps)
]
if unrecognized:
raise ValueError(f"Some news fragments have invalid names: {unrecognized}")


def get_version():
"""
>>> str(get_version())
Expand Down

0 comments on commit 364b0b7

Please sign in to comment.