aboutsummaryrefslogtreecommitdiff
path: root/maintainers
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-26 18:32:25 +0100
committereldritch horrors <pennae@lix.systems>2024-03-27 03:09:14 +0000
commit279e30e7ef4cae96d1f5fcbc5fc02ebb4779199b (patch)
tree045935b89a5067c297cb50e7a28ca3a81cf411fc /maintainers
parent8fd02df90d2a8099d2d547e151b876f77fb5a4a2 (diff)
build: replace changelog-d with local script
hacking changelog-d to support not just github but also forgejo and gerrit is a lot more complicated than it's worth, even moreso since the entire thing can just as well be done with ~60 lines of python. this new script is also much cheaper to instantiate (being python), so having it enabled in all shells is far less of a hassle. we've also adjusted existing release notes that referenced a gerrit cl to auto-link to the cl in question, making the diff a bit bigger closes https://git.lix.systems/lix-project/lix/issues/176 Change-Id: I8ba7dd0070aad9ba4474401731215fcf5d9d2130
Diffstat (limited to 'maintainers')
-rw-r--r--maintainers/build-release-notes.nix6
-rwxr-xr-xmaintainers/build-release-notes.py66
-rwxr-xr-xmaintainers/release-notes2
3 files changed, 73 insertions, 1 deletions
diff --git a/maintainers/build-release-notes.nix b/maintainers/build-release-notes.nix
new file mode 100644
index 000000000..9462e33d7
--- /dev/null
+++ b/maintainers/build-release-notes.nix
@@ -0,0 +1,6 @@
+{ lib, python3, writeShellScriptBin }:
+
+writeShellScriptBin "build-release-notes" ''
+ exec ${lib.getExe (python3.withPackages (p: [ p.python-frontmatter ]))} \
+ ${./build-release-notes.py} "$@"
+''
diff --git a/maintainers/build-release-notes.py b/maintainers/build-release-notes.py
new file mode 100755
index 000000000..ba645d19a
--- /dev/null
+++ b/maintainers/build-release-notes.py
@@ -0,0 +1,66 @@
+import frontmatter
+import sys
+import pathlib
+import textwrap
+
+GH_BASE = "https://github.com/NixOS/nix"
+FORGEJO_BASE = "https://git.lix.systems/lix-project/lix"
+GERRIT_BASE = "https://gerrit.lix.systems/c/lix/+"
+
+SIGNIFICANCECES = {
+ None: 0,
+ 'significant': 10,
+}
+
+def format_link(ident: str, gh_part: str, fj_part: str) -> str:
+ # FIXME: deprecate github as default
+ if ident.isdigit():
+ num, link, base = int(ident), f"#{ident}", f"{GH_BASE}/{gh_part}"
+ elif ident.startswith("gh#"):
+ num, link, base = int(ident[3:]), ident, f"{GH_BASE}/{gh_part}"
+ elif ident.startswith("fj#"):
+ num, link, base = int(ident[3:]), ident, f"{FORGEJO_BASE}/{fj_part}"
+ else:
+ raise Exception("unrecognized reference format", ident)
+ return f"[{link}]({base}/{num})"
+
+def format_issue(issue: str) -> str:
+ return format_link(issue, "issues", "issues")
+def format_pr(pr: str) -> str:
+ return format_link(pr, "pull", "pulls")
+def format_cl(cl: str) -> str:
+ clid = int(cl)
+ return f"[cl/{clid}]({GERRIT_BASE}/{clid})"
+
+paths = pathlib.Path(sys.argv[1]).glob('*.md')
+entries = []
+for p in paths:
+ try:
+ e = frontmatter.load(p)
+ if 'synopsis' not in e.metadata:
+ raise Exception('missing synposis')
+ unknownKeys = set(e.metadata.keys()) - set(('synopsis', 'cls', 'issues', 'prs', 'significance'))
+ if unknownKeys:
+ raise Exception('unknown keys', unknownKeys)
+ entries.append((p, e))
+ except Exception as e:
+ e.add_note(f"in {p}")
+ raise
+
+for p, entry in sorted(entries, key=lambda e: (-SIGNIFICANCECES[e[1].metadata.get('significance')], e[0])):
+ try:
+ header = entry.metadata['synopsis']
+ links = []
+ links += map(format_issue, str(entry.metadata.get('issues', "")).split())
+ links += map(format_pr, str(entry.metadata.get('prs', "")).split())
+ links += map(format_cl, str(entry.metadata.get('cls', "")).split())
+ if links != []:
+ header += " " + " ".join(links)
+ if header:
+ print(f"- {header}")
+ print()
+ print(textwrap.indent(entry.content, ' '))
+ print()
+ except Exception as e:
+ e.add_note(f"in {p}")
+ raise
diff --git a/maintainers/release-notes b/maintainers/release-notes
index 34cd85a56..c7a4e5074 100755
--- a/maintainers/release-notes
+++ b/maintainers/release-notes
@@ -152,7 +152,7 @@ section_title="Release $version_full ($DATE)"
# TODO add minor number, and append?
echo "# $section_title"
echo
- changelog-d doc/manual/rl-next | sed -e 's/ *$//'
+ build-release-notes doc/manual/rl-next
) | tee -a $file
log "Wrote $file"