add a weekly workflow refreshing FAME.md

The workflow runs scripts/fame.py against master every Monday and opens a
pull request if the contributor statistics changed.

For that to be quiet in weeks where nothing changed, fame.py now leaves
FAME.md alone when only the generation date would differ.
This commit is contained in:
Thomas Waldmann
2026-08-02 11:34:35 +02:00
parent 2923ac6421
commit 79bd383aa2
2 changed files with 88 additions and 1 deletions
+17 -1
View File
@@ -16,16 +16,23 @@ later refactored away, so it is not what we rank by.
Author identities are merged via .mailmap, so fix duplicates there rather than
here.
FAME.md is left alone if only the generation date would change, so that running
this regularly (see .github/workflows/fame.yml) does not produce a diff for a
week in which the statistics did not move.
"""
import argparse
import json
import re
import subprocess
from datetime import date
from pathlib import Path
BRANCH = "master"
DATE_LINE = re.compile(r"^Generated on \d{4}-\d{2}-\d{2} ", re.MULTILINE)
# Generated and binary-ish files would drown out hand-written code. Excalidraw
# scenes are the worst offenders: they are pretty-printed JSON, so a single
# diagram of a few boxes and arrows is over 10000 lines. Image formats are
@@ -84,6 +91,11 @@ def render(rows, total, contributors):
return preamble + "\n".join(table) + "\n"
def same_statistics(old, new):
"""Return True if the two FAME.md contents differ only in the generation date."""
return DATE_LINE.sub("Generated on ", old) == DATE_LINE.sub("Generated on ", new)
def main():
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--top", type=int, default=0, metavar="N", help="only list the top N contributors")
@@ -95,7 +107,11 @@ def main():
if args.top:
rows = rows[: args.top]
output = repo / "FAME.md"
output.write_text(render(rows, total, contributors), encoding="utf-8")
new = render(rows, total, contributors)
if output.exists() and same_statistics(output.read_text(encoding="utf-8"), new):
print(f"{output} is up to date ({len(rows)} of {contributors} contributors)")
return
output.write_text(new, encoding="utf-8")
print(f"wrote {output} ({len(rows)} of {contributors} contributors)")