Skip to content

Commit

Permalink
Update CHANGES checker to support multiple files for the same issue (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Oct 27, 2021
1 parent d379c6b commit 0fc598c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
File renamed without changes.
11 changes: 6 additions & 5 deletions tools/check_changes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3

import re
import sys
from pathlib import Path

ALLOWED_SUFFIXES = [".feature", ".bugfix", ".doc", ".removal", ".misc"]
ALLOWED_SUFFIXES += [f"{suffix}.rst" for suffix in ALLOWED_SUFFIXES]
ALLOWED_SUFFIXES = ["feature", "bugfix", "doc", "removal", "misc"]
PATTERN = re.compile(r"\d+\.(" + "|".join(ALLOWED_SUFFIXES) + r")(\.d+)?(.rst)?")


def get_root(script_path):
Expand All @@ -25,15 +26,15 @@ def main(argv):
for fname in changes.iterdir():
if fname.name in (".gitignore", ".TEMPLATE.rst", "README.rst"):
continue
if fname.suffix not in ALLOWED_SUFFIXES:
if not PATTERN.match(fname.name):
if not failed:
print("")
print(fname, "has illegal suffix", file=sys.stderr)
print("Illegal CHANGES record", fname, file=sys.stderr)
failed = True

if failed:
print("", file=sys.stderr)
print("Allowed suffixes are:", ALLOWED_SUFFIXES, file=sys.stderr)
print("See ./CHANGES/README.rst for the naming instructions", file=sys.stderr)
print("", file=sys.stderr)
else:
print("OK")
Expand Down

0 comments on commit 0fc598c

Please sign in to comment.