Skip to content

Commit

Permalink
Fix tool/cleanup_changes.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Nov 1, 2021
1 parent 15f4411 commit 6ce5234
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tools/cleanup_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
# Run me after the backport branch release to cleanup CHANGES records
# that was backported and publiched.

import re
import subprocess
from pathlib import Path

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


def main():
root = Path(__file__).parent.parent
delete = []
changes = (root / "CHANGES.rst").read_text()
for fname in (root / "CHANGES").iterdir():
if fname.name.startswith("."):
continue
if fname.stem in changes:
subprocess.run(["git", "rm", fname])
delete.append(fname.name)
match = PATTERN.match(fname.name)
if match is not None:
num = match.group(1)
tst = f"`#{num} <https://github.com/aio-libs/aiohttp/issues/{num}>`_"
if tst in changes:
subprocess.run(["git", "rm", fname])
delete.append(fname.name)
print("Deleted CHANGES records:", " ".join(delete))
print("Please verify and commit")

Expand Down

0 comments on commit 6ce5234

Please sign in to comment.