#!/usr/bin/env python3 """Print a GitHub Release change list from the commit subjects of a public release tag. Usage: generate-change-list.py Prints nothing when no earlier release tag exists. """ import importlib.util import re import subprocess import sys from pathlib import Path def load_script(name, filename): spec = importlib.util.spec_from_file_location(name, Path(__file__).with_name(filename)) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module policy = load_script("release_policy", "release-policy.py") SUBJECT_RE = re.compile( r"^(?P[A-Za-z]+)(?:\((?P[^)]*)\))?(?P!)?:\s*(?P\S.*)$" ) SECTIONS = (("feat", "New features"), ("fix", "Fixes"), ("perf", "Performance")) INTERNAL_SCOPES = frozenset(("release", "ci", "test", "tests")) # Pull request numbers in subjects belong to the private repository; on the public # release page they would link to unrelated items, and @names would notify people. TRAILING_PR_RE = re.compile(r"\s*\(#\d+\)$") REFERENCE_RE = re.compile(r"[\w.-]+/[\w.-]+#\d+|\bGH-\d+\b|(? \n") return 2 sys.stdout.write(change_list(argv[1], argv[2])) return 0 if __name__ == "__main__": raise SystemExit(main(sys.argv))