From 0dabdcfe4de99147a07bd577804b60818ea25bc4 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:40:49 -0300 Subject: [PATCH] Include co-authors in release announcement (#12795) (#12797) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As noted in #12789, the `release.py` script did not consider `Co-authored-by` fields, and since we introduced the new backport bot, this problem became more apparent due to how the backport commit and PR are generated. Previously, the list of authors produced by the script in the #12789 branch was: ``` * Avasam * Bruno Oliveira * Ronny Pfannschmidt * Sviatoslav Sydorenko (Святослав Сидоренко) ``` With this script: ``` * Anthony Sottile * Avasam * Bruno Oliveira * Christian Clauss * Eugene Mwangi * Florian Bruhin * GTowers1 * Nauman Ahmed * Pierre Sassoulas * Reagan Lee * Ronny Pfannschmidt * Stefaan Lippens * Sviatoslav Sydorenko (Святослав Сидоренко) * dongfangtianyu ``` (cherry picked from commit e8504ed49be73e516ee1559a250daec659e96b9d) Co-authored-by: Bruno Oliveira --- scripts/release.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 545919cd60b..aef5d6d5f73 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -6,6 +6,7 @@ import argparse import os from pathlib import Path +import re from subprocess import call from subprocess import check_call from subprocess import check_output @@ -16,17 +17,27 @@ def announce(version: str, template_name: str, doc_version: str) -> None: """Generates a new release announcement entry in the docs.""" - # Get our list of authors + # Get our list of authors and co-authors. stdout = check_output(["git", "describe", "--abbrev=0", "--tags"], encoding="UTF-8") last_version = stdout.strip() + rev_range = f"{last_version}..HEAD" - stdout = check_output( - ["git", "log", f"{last_version}..HEAD", "--format=%aN"], encoding="UTF-8" + authors = check_output( + ["git", "log", rev_range, "--format=%aN"], encoding="UTF-8" + ).splitlines() + + co_authors_output = check_output( + ["git", "log", rev_range, "--format=%(trailers:key=Co-authored-by) "], + encoding="UTF-8", ) + co_authors: list[str] = [] + for co_author_line in co_authors_output.splitlines(): + if m := re.search(r"Co-authored-by: (.+?)<", co_author_line): + co_authors.append(m.group(1).strip()) contributors = { name - for name in stdout.splitlines() + for name in authors + co_authors if not name.endswith("[bot]") and name != "pytest bot" }