From nobody Fri Apr 26 06:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42283+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42283+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560338396; cv=none; d=zoho.com; s=zohoarc; b=i5yoULeB9J3XdPjBzwSuq5pmNnY5MqxZLLHDQltfEEZTWkRr8IsqcJzomJoqzSr0EulBPDCXU/2shLk0xlf+yAHYwMmdqXRQx1JKk8ERJ5B7Qhkz76vrz9svg90srUM/vBAuuYwVTfIu/uCXD5jiZQNDEwp8Aw9Tde3RbA8C70w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560338396; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=9H1poSy8diiFf6mlM+B6xQuBsg+EexeLa01uTRt7zJQ=; b=Hq4vh2LlrVvhcQbXUqXqFS81h1eFCe2b32qNw4t6S40aKC8Hy4zahyO/NNtCtbRbRtuclRsmhRt8GGDC3R13FfOMZ5eCD2lny+6e071Pvblwg7P5LI9FZ0x87jI3BAMGxMOz2lQnGh8Y4vlF0JfWFY3uRgRYD5BglWu0gEtMIHo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42283+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1560338396839512.3338947473345; Wed, 12 Jun 2019 04:19:56 -0700 (PDT) Return-Path: X-Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by groups.io with SMTP; Wed, 12 Jun 2019 04:19:55 -0700 X-Received: by mail-wm1-f65.google.com with SMTP id a15so6133716wmj.5 for ; Wed, 12 Jun 2019 04:19:55 -0700 (PDT) X-Gm-Message-State: APjAAAVlWPQgxOAtVop17CAOx1Gr6EblEl90PdTC3HDiCMrWs+PKajvP vaX8oTAq8xa/2DAVHSNeUxK0aBYCZxPCtw== X-Google-Smtp-Source: APXvYqzyK3Q5shZWkwMhLoYiQmfVMbXWahDdXjQfQfG9FSjBBheHq2Xcy5K6uMXvRyLjvykI9Kncyw== X-Received: by 2002:a1c:3b02:: with SMTP id i2mr20331734wma.23.1560338393421; Wed, 12 Jun 2019 04:19:53 -0700 (PDT) X-Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id o14sm15348133wrp.77.2019.06.12.04.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2019 04:19:52 -0700 (PDT) From: "Leif Lindholm" To: devel@edk2.groups.io Cc: "Feng, Bob C" , Liming Gao , Andrew Fish , Laszlo Ersek , Michael D Kinney Subject: [edk2-devel] [BIKESHEDDING-TARGET] BaseTools: add GetMaintainer.py helper script Date: Wed, 12 Jun 2019 12:19:51 +0100 Message-Id: <20190612111951.2429-1-leif.lindholm@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,leif.lindholm@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560338396; bh=QdDw4gBLaKQgeBmkIZ4DdFwCyCHLNlWqUP1EB1ZHN6g=; h=Cc:Date:From:Reply-To:Subject:To; b=RHfm8ZTsmi/h8VuwIOYQnSx2B2bfzKHJvo3HGRxqy12nrcNRBlqFAj8iDKovG3qtT2P p2yCFlU77V4dzOHjbglHMtXG4HA+HWcp2nV+6IGGwr49O3KpN7KHRCMObUtnhM6jAFscn 3CI8mkMip4rSqjBcq/hFKGLirqyo7XFbRlQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is work-in-progress, but I figured it would be a good time to start having a conversation about how we want it to work. The script currently does nothing clever whatsoever with regards to looking at historical contributors to the modified code - it only performs a lookup in Maintainers.txt. Known shortcomings: - Does not provide any metainformation about why certain people or mailing lists were picked. - Does not reason about precedence of sections - all maintainers for all sections that match a wildcard are returned. - Does not substantially update Maintainers.txt. - Does not implement the X: tag, to explicitly exclude subpaths. (But scans for it.) - The splitting of Maintainers.txt into sections is based on directly adjacent lines starting with a valid tag (so I expect Star is left out from MdeModulePkg hits, and OvmfPkg loses most of its Reviewers. (My feeling is this is valid, and Maintainers.txt should change - certainly all the problematic lines would become redundant with this format change.) Supported wildcards are '*' and '?' - there is no special treatment of trailing '/' at this point. Oh, and like 'SetupGit.py', it requires the gitpython module. Laszlo: if you could provide some english language description of how the path (F:) format is supposed to work, and how you think section precedence should happen, I can implement that. The qemu MAINTAINERS file does not contain this information, and my perl knowledge is rustier than my python knowledge is incomplete. Signed-off-by: Leif Lindholm --- BaseTools/Scripts/GetMaintainer.py | 131 +++++++++++++++++++++++++++++++++= ++++ Maintainers.txt | 38 +++++++++++ 2 files changed, 169 insertions(+) create mode 100644 BaseTools/Scripts/GetMaintainer.py diff --git a/BaseTools/Scripts/GetMaintainer.py b/BaseTools/Scripts/GetMain= tainer.py new file mode 100644 index 0000000000..939930b052 --- /dev/null +++ b/BaseTools/Scripts/GetMaintainer.py @@ -0,0 +1,131 @@ +## @file +# Retrieves the people to request review from on submission of a commit. +# +# Copyright (c) 2019, Linaro Ltd. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +from __future__ import print_function +from collections import defaultdict +from collections import OrderedDict +import argparse +import os +import re +import SetupGit + +EXPRESSIONS =3D { + 'exclude': re.compile(r'^X:\s*(?P.*?)\r*$'), + 'file': re.compile(r'^F:\s*(?P.*?)\r*$'), + 'list': re.compile(r'^L:\s*(?P.*?)\r*$'), + 'maintainer': re.compile(r'^M:\s*(?P.*<.*?>)\r*$'), + 'reviewer': re.compile(r'^R:\s*(?P.*?)\r*$'), + 'status': re.compile(r'^S:\s*(?P.*?)\r*$'), + 'tree': re.compile(r'^T:\s*(?P.*?)\r*$'), + 'webpage': re.compile(r'^W:\s*(?P.*?)\r*$') +} + +def printsection(section): + """Prints out the dictionary describing a Maintainers.txt section.""" + print('=3D=3D=3D') + for key in section.keys(): + print("Key: %s" % key) + for item in section[key]: + print(' %s' % item) + +def pattern_to_regex(pattern): + """Takes a string containing regular UNIX path wildcards + and returns a string suitable for matching with regex.""" + pattern =3D pattern.replace('.', r'\.') + pattern =3D pattern.replace('*', r'.*') + pattern =3D pattern.replace('?', r'.') + + return pattern + +def get_section_maintainers(path, section): + """Returns a list with email addresses to any M: and R: entries + matching the provided path in the provided section.""" + maintainers =3D [] + + for pattern in section['file']: + regex =3D pattern_to_regex(pattern) + match =3D re.match(regex, path) + if match: +# print('path: "%s" pattern: "%s" regex: "%s"' % (path, pattern= , regex)) + for address in section['maintainer'], section['reviewer']: + maintainers +=3D address + + return maintainers + +def get_maintainers(path, sections): + """For 'path', iterates over all sections, returning maintainers + for matching ones.""" + maintainers =3D [] + for section in sections: + addresses =3D get_section_maintainers(path, section) + if addresses: + maintainers +=3D addresses + + # Remove any duplicates + return list(OrderedDict.fromkeys(maintainers)) + +def parse_maintainers_line(line): + """Parse one line of Maintainers.txt, returning any match group and it= s key.""" + for key, expression in EXPRESSIONS.items(): + match =3D expression.match(line) + if match: + return key, match.group(key) + return None, None + +def parse_maintainers_file(filename): + """Parse the Maintainers.txt from top-level of repo and + return a list containing dictionaries of all sections.""" + with open(filename, 'r') as text: + line =3D text.readline() + sectionlist =3D [] + section =3D defaultdict(list) + while line: + key, value =3D parse_maintainers_line(line) + if key and value: + section[key].append(value) + + line =3D text.readline() + # If end of section (end of file, or non-tag line encountered)= ... + if not key or not value or not line: + # ...if non-empty, append area to list. + if section: + sectionlist.append(section.copy()) + section.clear() + + return sectionlist + +def get_modified_files(repo, args): + """Returns a list of the files modified by the commit specified in 'ar= gs'.""" + commit =3D repo.commit(args.commit) + return commit.stats.files + +if __name__ =3D=3D '__main__': + PARSER =3D argparse.ArgumentParser( + description=3D'Retrieves information on who to cc for review on a = given commit') + PARSER.add_argument('commit', + action=3D"store", + help=3D'git revision to examine (default: HEAD)', + nargs=3D'?', + default=3D'HEAD') + ARGS =3D PARSER.parse_args() + + REPO =3D SetupGit.locate_repo() + + FILES =3D get_modified_files(REPO, ARGS) + CONFIG_FILE =3D os.path.join(REPO.working_dir, 'Maintainers.txt') + + SECTIONS =3D parse_maintainers_file(CONFIG_FILE) + + ADDRESSES =3D [] + + for file in FILES: + print(file) + ADDRESSES +=3D get_maintainers(file, SECTIONS) + + for address in list(OrderedDict.fromkeys(ADDRESSES)): + print(' %s' % address) diff --git a/Maintainers.txt b/Maintainers.txt index 762a684659..f4c851536e 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -47,6 +47,7 @@ T: svn (read-only, deprecated) - https://svn.code.sf.net/= p/edk2/code/trunk/edk2 =20 Tianocore Stewards ------------------ +F: * M: Andrew Fish M: Laszlo Ersek M: Leif Lindholm @@ -61,19 +62,30 @@ EDK II Releases: W: https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Pl= anning M: Liming Gao =20 +EDK II Architectures: +--------------------- +ARM, AARCH64 +F: */AARCH64/* +F: */ARM/* +M: Leif Lindholm +M: Ard Biesheuvel + EDK II Packages: ---------------- ArmPkg +F: ArmPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/ArmPkg M: Leif Lindholm M: Ard Biesheuvel =20 ArmPlatformPkg +F: ArmPlatformPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/ArmPlatformPkg M: Leif Lindholm M: Ard Biesheuvel =20 ArmVirtPkg +F: ArmVirtPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/ArmVirtPkg M: Laszlo Ersek M: Ard Biesheuvel @@ -81,26 +93,31 @@ R: Julien Grall (Xen modules) =20 BaseTools +F: BaseTools/* W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools M: Bob Feng M: Liming Gao =20 CryptoPkg +F: CryptoPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/CryptoPkg M: Jian Wang R: Ting Ye =20 DynamicTablesPkg +F: DynamicTablesPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/DynamicTablesPkg M: Sami Mujawar M: Alexei Fedorov =20 EmbeddedPkg +F: EmbeddedPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/EmbeddedPkg M: Leif Lindholm M: Ard Biesheuvel =20 EmulatorPkg +F: EmulatorPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg M: Jordan Justen M: Andrew Fish @@ -108,55 +125,65 @@ M: Ray Ni S: Maintained =20 FatPkg +F: FatPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/Edk2-fat-driver M: Ray Ni T: svn - https://svn.code.sf.net/p/edk2-fatdriver2/code/trunk/EnhancedFat T: git - https://github.com/tianocore/edk2-FatPkg.git =20 FmpDevicePkg +F: FmpDevicePkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/FmpDevicePkg M: Liming Gao M: Michael D Kinney =20 IntelFrameworkModulePkg +F: IntelFrameworkModulePkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFrameworkMod= ulePkg M: Liming Gao =20 IntelFrameworkPkg +F: IntelFrameworkPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFrameworkPkg M: Michael D Kinney M: Liming Gao =20 IntelFsp2Pkg +F: IntelFsp2Pkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg M: Chasel Chiu R: Nate DeSimone R: Star Zeng =20 IntelFsp2WrapperPkg +F: IntelFsp2WrapperPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2WrapperP= kg M: Chasel Chiu R: Nate DeSimone R: Star Zeng =20 IntelFspPkg +F: IntelFspPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFspPkg M: Chasel Chiu R: Nate DeSimone R: Star Zeng =20 IntelFspWrapperPkg +F: IntelFspWrapperPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFspWrapperPkg M: Chasel Chiu R: Nate DeSimone R: Star Zeng =20 IntelSiliconPkg +F: IntelSiliconPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/IntelSiliconPkg M: Ray Ni M: Rangasai V Chaganty =20 MdeModulePkg +F: MdeModulePkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/MdeModulePkg M: Jian J Wang M: Hao A Wu @@ -166,16 +193,19 @@ R: Ray Ni R: Star Zeng =20 MdePkg +F: MdePkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg M: Michael D Kinney M: Liming Gao =20 NetworkPkg +F: NetworkPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg M: Siyuan Fu M: Jiaxin Wu =20 OvmfPkg +F: OvmfPkg/* W: http://www.tianocore.org/ovmf/ M: Jordan Justen M: Laszlo Ersek @@ -191,16 +221,19 @@ R: Stefan Berger S: Maintained =20 PcAtChipsetPkg +F: PcAtChipsetPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/PcAtChipsetPkg M: Ray Ni =20 SecurityPkg +F: SecurityPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/SecurityPkg M: Chao Zhang M: Jiewen Yao M: Jian Wang =20 ShellPkg +F: ShellPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/ShellPkg M: Jaben Carsey M: Ray Ni @@ -214,21 +247,25 @@ M: Leif Lindholm (ARM/AA= rch64) M: Ard Biesheuvel (ARM/AArch64) =20 SignedCapsulePkg +F: SignedCapsulePkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/SignedCapsulePkg M: Jiewen Yao M: Chao Zhang =20 SourceLevelDebugPkg +F: SourceLevelDebugPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/SourceLevelDebugP= kg M: Hao A Wu =20 UefiCpuPkg +F: UefiCpuPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg M: Eric Dong M: Ray Ni R: Laszlo Ersek =20 UefiPayloadPkg +F: UefiPayloadPkg/* W: https://github.com/tianocore/tianocore.github.io/wiki/UefiPayloadPkg M: Maurice Ma M: Guo Dong @@ -236,6 +273,7 @@ M: Benjamin You S: Maintained =20 StandaloneMmPkg +F: StandaloneMmPkg/* M: Achin Gupta M: Jiewen Yao R: Supreeth Venkatesh --=20 2.11.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42283): https://edk2.groups.io/g/devel/message/42283 Mute This Topic: https://groups.io/mt/32039777/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-