From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7A1EA0C4B for ; Mon, 8 Nov 2021 07:29:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B332040151; Mon, 8 Nov 2021 07:29:31 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by mails.dpdk.org (Postfix) with ESMTP id DC169410FC for ; Mon, 8 Nov 2021 07:29:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RKHqrYRHKGYKW3/OuMv9X/bWo91a37iacFhoREjJz3w6X5m0ci7U2QsajVIO3wOxTLqbmzD4JDkH+FfxPh5VwSIC+ow2IGsUMDJvqTXyCqk3kkZmTbLpISnRkx7WxvKoxIBWdEsOr7iUhHts8ZSzL90UP6KpVb9PBiuNEhL8iQusRLMozORdZlFgpkowQHVaIQHDO8byc5LEqCzNyUXqO1GhWniUftaOJzrv7Zhzn0mfbEhXhVIRZk5/Jms2OquDlhvEWVaWY2rxml6mGfDhhDrx1Ic0uUyF0MKkePkGFzK7BdtEw4SfMaHxML262VprIRC0ZSInPqPg0+Tk7OvwOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NqlrP929RTHRvN80JKnDLrNxVJwmkLqCUeslrJ3mVvg=; b=ASNbZ2GT2TDJe1x69RmoUEHkkK4+6v5gSoKW8jA9UoU5AdQb5orIkmhe9ze/UdL8XiqDnp/xv15nwgy0bJiMZwegBoV7Ei2t71foWiUHu9WU1DkgvPhXUinNFhMucoX3LE2jRUNBcfP4jMNMFBVaI1O2YuR0vtC8bcV4r/BhqJkRFOy834H02Tivz4FLEyS3BjF0mzZ3xkNAFsD1YH7NUcAXGUBhAIFqWmzfy3LV3LxpuCaNvVMNcrSaxcoo4h21RusRBjG1QMMkHXz05iY3AZ+tkV3005iaQAAPOuXVI336Tl9YjFXXSkugF2rRxKNt+ROMOEY33TUnb4p607pw+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NqlrP929RTHRvN80JKnDLrNxVJwmkLqCUeslrJ3mVvg=; b=XrOJPFgvdUTg9P/Ub1BJZULk2kX+ISPd/2gz+pDk5FoaxWAFNNo9bgxo+i0dhR2FzbVSqkjGb5GzOVpHuIQaz81qS3Bb9R+nrjKajueRVHF6/ILbQhQWO3TYjjUjL8bfGT75pQ+40Hc3E7MqPgfZkOCtYSLRpY87TVHeUw5cVgwkAwKv14lYMohxEMbjQrlSwUC3+qGKYakVYKVXENxhmx5tCFCxQng0bLd3nBhfcMhc02zCBpluH5KYFHCsF5csELC/hE/8gud4ov7WdpvdkPhaoANvRsxCbpmqdczxEfhaOxOJok3kiQzTD7ClrWpI9T4brQf9nLkHTWwbwARxdQ== Received: from DM6PR03CA0050.namprd03.prod.outlook.com (2603:10b6:5:100::27) by MWHPR12MB1438.namprd12.prod.outlook.com (2603:10b6:300:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Mon, 8 Nov 2021 06:29:26 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::73) by DM6PR03CA0050.outlook.office365.com (2603:10b6:5:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Mon, 8 Nov 2021 06:29:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 06:29:25 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov 2021 06:29:21 +0000 From: Ali Alnubani To: CC: , , , , Date: Mon, 8 Nov 2021 08:28:09 +0200 Message-ID: <20211108062815.7614-5-alialnu@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211108062815.7614-1-alialnu@nvidia.com> References: <20210906154537.1299-1-alialnu@nvidia.com> <20211108062815.7614-1-alialnu@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1e64d66-c2be-48c0-7ba1-08d9a2811c16 X-MS-TrafficTypeDiagnostic: MWHPR12MB1438: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:446; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tmAhlzefQjO1LJtXtIOt+OiF0CP9VR88WotoAYfClJEuQWFkgEN6Fq/CAGySvrQIuwrnDfZCXAiYrC2pp2q8yHBpeNz50ZiaBYC/9rI6xoXxLD41ubY1O4z4csWhWqfMWindX0QeTkWpdNjfgEuiKQRH7h6cG9KgzmKW6H1I9LkOrQElmJ3u8cybPX8oh/bSpG6db1ks6WQ0e8iIZaBogNhLtO2oyxLzVPv0+qvzsYHjjNEm3Ph5czlZJ9P9Yeq/r6UuziRfO3zWmLvwlZ1z1GFUFTbc+Mo08WCwyh3G3LqdZgvlsJnmeWnZmiVK6dS4q6m8/uH7oJytgxnIrg7Vz+CIFbwLhNS4xSLCMZapfA2Dstbd4ITbsN8wEWxjWX3pflRj8CI2ylxlwaRH9oFWeKGA0EAVPjZ0/5yjvmEOrnop43E+99i9UYVfIrlHullo7EIzvVbYa8Llar1aIDp6qShn/ZiqKa9xcAbORy2Rol8oS3GsyHOdX7C8+kc6sShVojAuAiq7sh37Sabi+d+yF5xdqmIpybJyxGUA8Ynk01BdB6lVt17SCFztE78xsCFtlvlWKJnbNOY/kdrY9B+cBDR5hvRG4myeawsaxUxJ6+Cq7ri62XQ6XrZqMQ2Ym7mTFYtg1THVt/spEcRmER2lugGzkxcuagbZdJLwRpnmv+cme6VLfcsad5ChFohn9pya/Zb6U1Vr+E5CsqvzMl0w4w== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(70206006)(70586007)(47076005)(8936002)(336012)(508600001)(426003)(83380400001)(36756003)(54906003)(6916009)(2616005)(7636003)(356005)(55016002)(6286002)(16526019)(186003)(2906002)(82310400003)(36906005)(316002)(5660300002)(4326008)(6666004)(7696005)(36860700001)(8676002)(26005)(86362001)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 06:29:25.4222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1e64d66-c2be-48c0-7ba1-08d9a2811c16 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1438 Subject: [dpdk-ci] [PATCH v4 04/10] tools: add functionality for detecting tree maintainers X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ci-bounces@dpdk.org Sender: "ci" Detecting a maintainer works by searching the 'General Project Administration' section for subsections containing the provided tree, and then returning the maintainers specified in that subsection. Signed-off-by: Ali Alnubani --- Changes in v3: - Stored 'General Project Administration' in a variable (Suggested by Thomas Monjalon). tools/pw_maintainers_cli.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index 67d8586..904be2e 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -33,6 +33,7 @@ to load the git configurations pw.{server,project,token}. Example usage: ./pw_maintainers_cli.py --type series list-trees 2054 ./pw_maintainers_cli.py --type patch list-trees 2054 + ./pw_maintainers_cli.py --type patch list-maintainers 2054 Or if you want to use inside other scripts: @@ -48,6 +49,7 @@ Or if you want to use inside other scripts: files = Diff.find_filenames(_git_pw.api_get('patches', patch_id)['diff']) tree_url = maintainers.get_tree(files) tree_name = tree_url.split('/')[-1] + maintainers = maintainers.get_maintainers(tree_url) """ @@ -118,8 +120,10 @@ class Maintainers(object): file_regex = r'F:\s(.*)' tree_regex = r'T: (?Pgit:\/\/dpdk\.org(?:\/next)*\/(?P.*))' + maintainer_regex = r'M:\s(.*)' section_regex = r'([^\n]*)\n-+.*?(?=([^\n]*\n-+)|\Z)' subsection_regex = r'[^\n](?:(?!\n{{2}}).)*?^{}: {}$(?:(?!\n{{2}}).)*' + general_proj_admin_title = 'General Project Administration' def __init__(self): with open(MAINTAINERS_FILE_PATH) as fd: @@ -141,6 +145,26 @@ class Maintainers(object): # Save already matched patterns. self.matched = {} + def get_maintainers(self, tree): + """ + Return a list of a tree's maintainers.""" + maintainers = [] + for section in self.sections: + if section.group(1) == self.general_proj_admin_title: + # Find the block containing the tree. + regex = self.subsection_regex.format('T', re.escape(tree)) + subsection_match = re.findall( + regex, + section.group(0), + re.DOTALL | re.MULTILINE) + if len(subsection_match): + subsection = subsection_match[-1] + # Look for maintainers + maintainers = re.findall( + self.maintainer_regex, subsection) + return maintainers + break + def get_tree(self, files): """ Return a git tree that matches a list of files.""" @@ -265,7 +289,7 @@ if __name__ == '__main__': parser.add_argument( 'command', choices=[ - 'list-trees'], + 'list-trees', 'list-maintainers'], help='Command to perform') parser.add_argument( 'id', type=int, help='patch/series id') @@ -301,3 +325,5 @@ if __name__ == '__main__': if command == 'list-trees': print(tree.split('/')[-1]) + elif command == 'list-maintainers': + print(*maintainers.get_maintainers(tree), sep='\n') -- 2.25.1