diff --git a/newsfragments/1690.misc.rst b/newsfragments/1690.misc.rst new file mode 100644 index 0000000000..17ccb1d140 --- /dev/null +++ b/newsfragments/1690.misc.rst @@ -0,0 +1 @@ +Adopt Trinity's newsfragment validation script. diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py old mode 100644 new mode 100755 index b60b8723df..b2ebbba1a6 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -5,13 +5,14 @@ import os import pathlib +import sys ALLOWED_EXTENSIONS = { - '.feature.rst', '.bugfix.rst', '.doc.rst', - '.removal.rst', + '.feature.rst', '.misc.rst', + '.removal.rst', } ALLOWED_FILES = { @@ -21,11 +22,20 @@ 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("Strange: arguments {sys.argv} were validated, but not found")