From nobody Sun Jan 25 12:07:23 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1769180323; cv=none; d=zohomail.com; s=zohoarc; b=mvLRoYqtEujpyB+S52mzX/hrMN5LTEXxwQRPGZz+grwZy89tYk7Q60F6RId0RyhU6xd7KHGeJ2m1J6PpKdRmnZpPNBebBaZWkJ9nVth5EMClPZZdxC1BGUxkvHNjwOWqW/05owFb0kRUK26HhX5dTEkB9i4CboRYH9VNKHSd0Js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769180323; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HHNWNw6bOL9uCXfJx/sXdBgGZyGqUJ5RbKAUe0K/1PU=; b=dQ0Zas4e9Z+scSlpJTkSHQn/OWgYqJO3QyNK16q88Fm+DejsO6D50wHUrIpwb8DoYzRxkEwU81o1qH3EMPz5D/2FbY1VV5Cb74XeNpxu7NpuoJwondN16fVxwYn+BvGH/TTG2saQzIaxm+cB89qOmgJ/z5KzJnX6OQ4709qwWSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769180323130208.77160026485046; Fri, 23 Jan 2026 06:58:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjIc9-0004P1-P5; Fri, 23 Jan 2026 09:58:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjIbz-0004IJ-Ke for qemu-devel@nongnu.org; Fri, 23 Jan 2026 09:58:12 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vjIbx-0007oa-UU for qemu-devel@nongnu.org; Fri, 23 Jan 2026 09:58:11 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-42fb5810d39so1443337f8f.2 for ; Fri, 23 Jan 2026 06:58:09 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1c24a6fsm7165060f8f.16.2026.01.23.06.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 06:58:04 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C55AC5FADA; Fri, 23 Jan 2026 14:57:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769180288; x=1769785088; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HHNWNw6bOL9uCXfJx/sXdBgGZyGqUJ5RbKAUe0K/1PU=; b=SbHhoe6NL0k5fkKeLvgNOlVx+jFthxJaKQCJVVltfjERlxZQDzFlJJ8AgMEqU1Vtyd ruzbmfqlp31ZTJ9I8u4MOcMMsV7zjvo9s6NLKWcbVThmdYJv1SIkQGIzF3xS8WniWd5d boe+rr63ooBgZielZ6n2QmM/F6jBhVc9a94wYwRPGZPyoPJCAzIe8ewbLJa/w9QSH0E2 PNCNDsppPcGH1CrBZcZfh0jM6FZNAhME8sIOTBp4zqmtfMZQETMxqrabwAPmLUxDtwN2 Wgir6p7no9/sfOwuISyIxXlovfA1CkRKOzj+sETc3VlwcwMPwXRJFzPe3dNlcg4DBfZ2 UOFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769180288; x=1769785088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HHNWNw6bOL9uCXfJx/sXdBgGZyGqUJ5RbKAUe0K/1PU=; b=X8YfAaRAiIFZwvPA6mQIsww0Fw6S998vtvlOZUqBDRuBmS6RApnNTle7Cm/cZjQGbl D2lxdEF95fLtyZZEfZNxuNikxZuWqIq/9wgKMnAgS25CcBZwny2/uYpsz9C50ium+3zS ougxkup/FlH+uqIkxl4GYMZYy7hQadVYnhbRvI0zXtqbarCThy7mEJRf7GCufyXuPcmV gTRCV/rf81Uu5c8d/+yxVtdRXuiAP5jxDBKyeOX/gsa33QUMcXT4yhzpoHYtLMzn/aPX BSb+lKTtL/8ZXrC4FuY6cjTb0ZAfcdNx4PPX3/m5LHYopUbZaB+0/F2Em4vFKXjKx/wN o7uw== X-Gm-Message-State: AOJu0YxkpdFJJAByfTgnNw2RCMhM/9rmGDVIYIzAF+y4q4qioQhZrK4x katj58YapEGH4qARQDEak0t2LV7O9QZwtGx6PieDgOhboDSXZBuPs9gW5Z9yAqHCucg= X-Gm-Gg: AZuq6aK6HdP7W0H9ZVAJzgQO+i4XbKOkIHjlFApsQr7bzXSF6nUHAOSgQ6+AT/MahBB KUedxrHxq1AUsQLSiMTwsuHxnQse+aF6o57Ruso/3TtZaXUBHgnhBMHKKi46oWTl1ht7PN31Dbr G+UZHFym9CcYE7D3Je7Jofwid941kgcQ48hCLN2cckDCqQr6vB2Bl5+KwyYA9lcZXn/48w5wmQ5 KD2UGCQkA9FqEF/NNrEn5KjrgjWaHbL6oE9BHjio0nTcNkzVClF8BE6Vg2ksEtMkIV8V6CcMkKb vjLhA0atCRbrb/BHAvxyveDyzw3yeRaClcHE9gLcM9rCXfVb4VvxVEcXesNiD5VIrJsT6gYvuc+ xFjjbFobqFhTUU7vL62ihPR8ZUyZCM7XMRHl25bhBu8Yb5zghKdG6s+NJz0e01owudcER3s0DEQ NjGbp4pUmjmEXM X-Received: by 2002:a05:6000:402a:b0:435:9882:2342 with SMTP id ffacd0b85a97d-435b1604b2bmr5159948f8f.33.1769180288143; Fri, 23 Jan 2026 06:58:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mauro Carvalho Chehab , Joe Perches , John Snow Subject: [RFC PATCH v2 15/16] scripts/get_maintainer.py: implement basic git fallback support Date: Fri, 23 Jan 2026 14:57:48 +0000 Message-ID: <20260123145750.1200879-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123145750.1200879-1-alex.bennee@linaro.org> References: <20260123145750.1200879-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1769180324882154100 Implement the basic --git fallback support which also needs --git-since and the various knobs to control the minimum and maximum signatures to look for. Signed-off-by: Alex Benn=C3=A9e --- scripts/get_maintainer.py | 125 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/scripts/get_maintainer.py b/scripts/get_maintainer.py index b41f5342876..de229a20bc2 100755 --- a/scripts/get_maintainer.py +++ b/scripts/get_maintainer.py @@ -11,12 +11,16 @@ # SPDX-License-Identifier: GPL-2.0-or-later =20 from argparse import ArgumentParser, ArgumentTypeError, BooleanOptionalAct= ion +from dataclasses import dataclass from os import path from pathlib import Path from enum import StrEnum, auto from re import compile as re_compile from re import sub as re_sub +from re import IGNORECASE from regex import compile as prec_compile +from git import Repo +from collections import Counter =20 # # Subsystem MAINTAINER entries @@ -230,6 +234,96 @@ def process_patch_file(patchfile): =20 return (msg, file_list) =20 +# +# Helpers for querying git +# + + +@dataclass +class GitOptions: + repo: Repo + singers: bool + since: str + min_sig: int + max_maint: int + min_percent: int + + +def rank_signers(git_opts, all_signers, total_commits): + """ + Counts signer occurrences and returns a list of (Person, count, percen= t). + """ + if total_commits =3D=3D 0: + return [] + + # Count by email to handle duplicates/mailmap issues + counts =3D Counter(s.email for s in all_signers) + + # Keep a map of email -> Person object for the most recent name used + email_to_person =3D {p.email: p for p in all_signers} + + ranked_results =3D [] + + # Sort by count descending, then take the top N + for email, count in counts.most_common(git_opts.max_maint): + percent =3D min(100.0, (count / total_commits) * 100) + if percent >=3D git_opts.min_percent: + person =3D email_to_person[email] + ranked_results.append((person, count, percent)) + + return ranked_results + + +# regex to extract name/email from *-by: tags +sig_line_re =3D re_compile(r"^\s*[\w-]+-by:\s*(?P.*)", IGNORE= CASE) + + +def extract_signers(commit_message): + """ + Return a list of Persons found in commit. + """ + signers =3D [] + for line in commit_message.splitlines(): + match =3D sig_line_re.match(line) + if match: + try: + p =3D Person(match.group('person_info')) + signers.append(p) + except BadPerson: + continue + return signers + + +def extract_from_git(git_opts, src_file): + """ + Extract 'maintainers' from examining the git history of a file. + Return an array of Person/role tuples. + """ + repo =3D git_opts.repo + + # use the porcelain to fetch the log + hashes =3D repo.git.log('--follow', f"--since=3D{git_opts.since}", + "--format=3D%H", '--', src_file).splitlines() + + if len(hashes) <=3D 0: + return [] + + commits =3D [repo.commit(h) for h in hashes] + + all_signers =3D [] + + for c in commits: + all_signers.extend(extract_signers(f"{c.message}")) + + ranked =3D rank_signers(git_opts, all_signers, len(commits)) + results =3D [] + + for person, count, percent in ranked: + role =3D f"commit_signer: {count}/{len(commits)}=3D{percent:.0f}%" + results.append((person, role)) + + return results + # # Helper functions for dealing with the source path # @@ -331,6 +425,22 @@ def main(): parser.add_argument('--src', type=3Dvalid_src_root, default=3Dsrc, help=3Df'Root of QEMU source tree{" (default: " + = src + ")" if src else ""}') =20 + # Git Options + parser.add_argument('--git', action=3DBooleanOptionalAction, + default=3DFalse, + help=3D"Include recent git *-by: signers (default:= don't)") + parser.add_argument('--git-since', default=3D"1-year-ago", + help=3D'git history to use when falling back (defa= ult: 1-year-ago)') + parser.add_argument('--git-fallback', + action=3DBooleanOptionalAction, default=3DTrue, + help=3D'use git when no exact MAINTAINERS pattern = (default: fallback)') + parser.add_argument('--git-min-signatures', default=3D1, + help=3D'number of signatures required (default: 1)= ') + parser.add_argument('--git-max-maintainers', default=3D5, + help=3D'maximum number of git derived maintainers = to add (default: 5)') + parser.add_argument('--git-min-percent', default=3D5, + help=3D'minimum percentage of commits to tagged as= a maintainer (default: 5)') + args =3D parser.parse_args() =20 try: @@ -369,6 +479,21 @@ def main(): for rm in maintained: print(str(rm)) =20 + # Git fallback + if args.git or (args.git_fallback and len(maintained) =3D=3D 0): + repo =3D Repo(src) + git_opts =3D GitOptions(repo=3Drepo, singers=3Dargs.git, + since=3Dargs.git_since, + min_sig=3Dargs.git_min_signatures, + max_maint=3Dargs.git_max_maintainers, + min_percent=3Dargs.git_min_percent) + + for f in files: + gmaint =3D extract_from_git(git_opts, f) + + for (person, role) in gmaint: + print(f"{person} ({role})") + =20 if __name__ =3D=3D '__main__': main() --=20 2.47.3