From e7bc3b248335d5ee570c71e7c192133c952d678e Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 10 Sep 2026 16:53:22 +0100 Subject: [PATCH] bin: make update-authors.py add multiple contributors in a single commit When more than one new contributor is found, list their names in the commit body rather than making one commit per person. --- bin/update-authors.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/update-authors.py b/bin/update-authors.py index d63ea6016..0c990e205 100755 --- a/bin/update-authors.py +++ b/bin/update-authors.py @@ -17,15 +17,28 @@ def load(filename): authors = fd.read() return set(re.findall(r"<(.*?)>", authors)) -def add_email(name, email): +def add_email(added, name, email): """ - adds the email passed in to the end of authors.md + adds the email passed in to the end of authors.md and records it in added """ print("Adding %s <%s>" % (name, email)) with open(AUTHORS, "a+") as fd: print("- %s <%s>" % (name, email), file=fd) - subprocess.check_call(["git", "commit", "-m", "Add %s to contributors" % name, AUTHORS]) - + added.append((name, email)) + +def commit(added): + """ + commits authors.md with a message describing the names in added + """ + if not added: + return + if len(added) == 1: + message = "Add %s to contributors" % added[0][0] + else: + message = "Add %d new contributors\n\n" % len(added) + message += "".join("- %s\n" % name for name, _ in added) + subprocess.check_call(["git", "commit", "-m", message, AUTHORS]) + def main(): # Add emails from authors out = subprocess.check_output(["git", "log", '--reverse', '--format=%an|%ae', "master"]) @@ -34,6 +47,7 @@ def main(): ignored = load(IGNORE) previous = load(AUTHORS) previous.update(ignored) + added = [] for line in out.split("\n"): line = line.strip() if line == "": @@ -42,7 +56,7 @@ def main(): if email in previous: continue previous.add(email) - add_email(name, email) + add_email(added, name, email) # Add emails from Co-authored-by: lines out = subprocess.check_output(["git", "log", '-i', '--grep', 'Co-authored-by:', "master"]) @@ -60,7 +74,9 @@ def main(): if email in previous: continue previous.add(email) - add_email(name, email) + add_email(added, name, email) + + commit(added) if __name__ == "__main__": main()