From 546c74e1fc65a009fdfed6d2e2989e8098d49964 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Fri, 18 Jul 2025 15:38:47 +1000 Subject: [PATCH] doc: hall of fame: support correcting names that are wrong We identified somebody whose name was malformed in git history such that they were credited wrong in the hall of fame, so add some code to handle names that manage to be committed with incorrect formatting. Signed-off-by: Peter Marheine Change-Id: I33b04932403b2d69da4648a3a7016aee57741d0d Reviewed-on: https://review.coreboot.org/c/flashrom/+/88477 Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- doc/_ext/flashrom_authors.py | 53 ++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/doc/_ext/flashrom_authors.py b/doc/_ext/flashrom_authors.py index f160d21e1..ff23a5547 100644 --- a/doc/_ext/flashrom_authors.py +++ b/doc/_ext/flashrom_authors.py @@ -1,3 +1,4 @@ +import collections from docutils import nodes from pathlib import Path from typing import TYPE_CHECKING @@ -13,17 +14,14 @@ class FlashromAuthorsDirective(SphinxDirective): required_arguments = 1 has_content = True - def make_table(self, list_file: Path): + def make_table(self, name_counts): body = nodes.tbody() - with list_file.open("r") as f: - for line in f: - count, _, name = line.strip().partition("\t") - - body += nodes.row( - "", - nodes.entry("", nodes.paragraph(text=name)), - nodes.entry("", nodes.paragraph(text=count)), - ) + for name, count in name_counts: + body += nodes.row( + "", + nodes.entry("", nodes.paragraph(text=name)), + nodes.entry("", nodes.paragraph(text=str(count))), + ) return nodes.table( "", @@ -68,7 +66,40 @@ class FlashromAuthorsDirective(SphinxDirective): self.state.nested_parse(self.content, 0, container) return [self.make_placeholder(container.children)] else: - return [self.make_table(Path(list_file))] + authors = self.count_authors_from_file(Path(list_file)) + return [self.make_table(authors.most_common())] + + @classmethod + def count_authors_from_file(cls, list_file: Path) -> collections.Counter: + # Correcting names may influence the count, so although git shortlog + # provides us a count there may be multiple entries in the file that + # must be combined into a single row. + counter = collections.Counter() + + with list_file.open("r") as f: + for line in f: + count, _, name = line.strip().partition("\t") + fixed_name = cls._correct_known_bad_name(name) + if fixed_name is not None: + counter[fixed_name] += int(count) + + return counter + + _INCORRECT_NAMES = { + # Commit 9ff3d4cf759161edf6c163f454f11bc9f5328ce3 is missing a '>' in a + # Co-Authored-By trailer, but this person is already credited as author + # of that commit so should not be double-counted. + "persmule 'ExtensionMetadata':