Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adopt trinity's newsfragment validation #1690

Merged
merged 2 commits into from
Jul 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions newsfragments/validate_files.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import os
import pathlib
import sys

ALLOWED_EXTENSIONS = {
'.feature.rst',
'.bugfix.rst',
'.doc.rst',
'.removal.rst',
wolovim marked this conversation as resolved.
Show resolved Hide resolved
'.feature.rst',
'.misc.rst',
}

Expand All @@ -21,11 +21,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")