diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-04-07 20:05:19 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-04-08 15:40:12 -0700 |
commit | 06f17a5c78c33120afd71a94f907bfdabd5c40aa (patch) | |
tree | 881e7af117ed774480b586decabce89f64b99330 | |
parent | 6fcab7ee9528123e0f115e6d79ea694bca6cd426 (diff) |
release-notes: check with pre-commit
This required making the build-release-notes script understand how to
check multiple directories.
Change-Id: I057f5f636155ab6c6fb5755da5217b7e72249ece
-rw-r--r-- | flake.nix | 9 | ||||
-rw-r--r-- | maintainers/build-release-notes.py | 75 |
2 files changed, 49 insertions, 35 deletions
@@ -344,6 +344,15 @@ enable = true; excludes = [ "^tests/functional/lang/" ]; }; + release-notes = { + enable = true; + package = pkgs.build-release-notes; + files = "^doc/manual/rl-next(-dev)?"; + pass_filenames = false; + entry = '' + ${lib.getExe pkgs.build-release-notes} doc/manual/rl-next doc/manual/rl-next-dev + ''; + }; # TODO: Once the test suite is nicer, clean up and start # enforcing trailing whitespace on tests that don't explicitly # check for it. diff --git a/maintainers/build-release-notes.py b/maintainers/build-release-notes.py index dd26fd1cb..2a154a61e 100644 --- a/maintainers/build-release-notes.py +++ b/maintainers/build-release-notes.py @@ -31,41 +31,46 @@ def format_pr(pr: str) -> str: def format_cl(clid: int) -> str: 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 synopsis') - 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 +def run_on_dir(d): + paths = pathlib.Path(d).glob('*.md') + entries = [] + for p in paths: + try: + e = frontmatter.load(p) + if 'synopsis' not in e.metadata: + raise Exception('missing synopsis') + 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 -def listify(l: list | int) -> list: - if not isinstance(l, list): - return [l] - else: - return l + def listify(l: list | int) -> list: + if not isinstance(l, list): + return [l] + else: + return l -for p, entry in sorted(entries, key=lambda e: (-SIGNIFICANCECES[e[1].metadata.get('significance')], e[0])): - try: - header = entry.metadata['synopsis'] - links = [] - links += [format_issue(str(s)) for s in listify(entry.metadata.get('issues', []))] - links += [format_pr(str(s)) for s in listify(entry.metadata.get('prs', []))] - links += [format_cl(cl) for cl in listify(entry.metadata.get('cls', []))] - if links != []: - header += " " + " ".join(links) - if header: - print(f"- {header}") + for p, entry in sorted(entries, key=lambda e: (-SIGNIFICANCECES[e[1].metadata.get('significance')], e[0])): + try: + header = entry.metadata['synopsis'] + links = [] + links += [format_issue(str(s)) for s in listify(entry.metadata.get('issues', []))] + links += [format_pr(str(s)) for s in listify(entry.metadata.get('prs', []))] + links += [format_cl(cl) for cl in listify(entry.metadata.get('cls', []))] + if links != []: + header += " " + " ".join(links) + if header: + print(f"- {header}") + print() + print(textwrap.indent(entry.content, ' ')) print() - print(textwrap.indent(entry.content, ' ')) - print() - except Exception as e: - e.add_note(f"in {p}") - raise + except Exception as e: + e.add_note(f"in {p}") + raise + +if __name__ == '__main__': + for d in sys.argv[1:]: + run_on_dir(d) |