Skip to content

Commit

Permalink
Update towncrier types to match the template repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed Apr 6, 2023
1 parent 0934c9f commit 72bb43e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
38 changes: 25 additions & 13 deletions newsfragments/validate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,43 @@
# Towncrier silently ignores files that do not match the expected ending.
# We use this script to ensure we catch these as errors in CI.

import os
import pathlib
import sys

ALLOWED_EXTENSIONS = {
'.feature.rst',
'.bugfix.rst',
'.performance.rst',
'.doc.rst',
'.removal.rst',
'.internal.rst',
'.misc.rst',
".breaking.rst",
".bugfix.rst",
".doc.rst",
".feature.rst",
".internal.rst",
".misc.rst",
".performance.rst",
".removal.rst",
}

ALLOWED_FILES = {
'validate_files.py',
'README.md',
"validate_files.py",
"README.md",
}

THIS_DIR = pathlib.Path(__file__).parent

num_args = len(sys.argv) - 1
assert num_args in {0, 1}
if num_args == 1:
assert sys.argv[1] in ("is-empty",)

for fragment_file in THIS_DIR.iterdir():

if fragment_file.name in ALLOWED_FILES:
continue

full_extension = "".join(fragment_file.suffixes)
if full_extension not in ALLOWED_EXTENSIONS:
elif num_args == 0:
full_extension = "".join(fragment_file.suffixes)
if full_extension not in ALLOWED_EXTENSIONS:
raise Exception(f"Unexpected file: {fragment_file}")
elif sys.argv[1] == "is-empty":
raise Exception(f"Unexpected file: {fragment_file}")
else:
raise RuntimeError(
f"Strange: arguments {sys.argv} were validated, but not found"
)
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ showcontent = true

[[tool.towncrier.type]]
directory = "internal"
name = "Internal Changes - for Contributors"
name = "Internal Changes - For Contributors"
showcontent = true

[[tool.towncrier.type]]
directory = "misc"
name = "Miscellaneous internal changes"
name = "Miscellaneous changes"
showcontent = false

[[tool.towncrier.type]]
directory = "breaking"
name = "Breaking changes"
showcontent = true

0 comments on commit 72bb43e

Please sign in to comment.