From 9e7fc833e94d3c82ea33762c5760ade576072bd3 Mon Sep 17 00:00:00 2001 From: purian23 Date: Wed, 15 Jul 2026 00:57:26 -0400 Subject: [PATCH] update release & changelog docs formatting port 1.5 (cherry picked from commit 3254cc6a1edb1bb94d90cbdbc1681cf934df6e01) --- scripts/release-notes.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/scripts/release-notes.py b/scripts/release-notes.py index 72b7c1cd8..61fe3884c 100755 --- a/scripts/release-notes.py +++ b/scripts/release-notes.py @@ -20,6 +20,7 @@ import re import subprocess import sys from collections import OrderedDict +from pathlib import Path BOT_RE = re.compile(r"\[bot\]$|^github-actions$|^dependabot$", re.I) # default blog-table exclusions @@ -311,6 +312,13 @@ def main(): help="github format: omit heading and Full Changelog footer") ap.add_argument("--no-api", action="store_true", help="skip GitHub API, use git data only (degraded attribution)") + ap.add_argument("-o", "--output", default=None, metavar="PATH", + help="write the output to PATH instead of stdout (parent dirs " + "are created)") + ap.add_argument("--version", default=None, metavar="X.Y.Z", + help="release version being cut; if set and -o/--output isn't, " + "writes to ~/Documents/dms-vX.Y.Z-changelog.md instead of " + "stdout") args = ap.parse_args() repo = args.repo @@ -329,16 +337,25 @@ def main(): drop = {x.lower() for x in excludes if x} if args.format == "blog": # blog excludes from tables only; fixes list keeps everyone - print(format_blog(repo, entries, args.range, exclude=drop)) - return 0 - if drop: - entries = [e for e in entries - if (e["login"] or "").lower() not in drop - and e["author_name"].lower() not in drop] - if args.format == "github": - print(format_github(repo, entries, args.range, bare=args.bare)) + text = format_blog(repo, entries, args.range, exclude=frozenset(drop)) else: - print(format_checklist(entries)) + if drop: + entries = [e for e in entries + if (e["login"] or "").lower() not in drop + and e["author_name"].lower() not in drop] + if args.format == "github": + text = format_github(repo, entries, args.range, bare=args.bare) + else: + text = format_checklist(entries) + + out_target = args.output or (f"~/Documents/dms-v{args.version}-changelog.md" if args.version else None) + if out_target: + out_path = Path(out_target).expanduser() + out_path.parent.mkdir(parents=True, exist_ok=True) + out_path.write_text(text + "\n") + print(f"written to {out_path}", file=sys.stderr) + else: + print(text) return 0