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 5A867A0C4B for ; Mon, 8 Nov 2021 07:29:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A90240151; Mon, 8 Nov 2021 07:29:22 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2076.outbound.protection.outlook.com [40.107.100.76]) by mails.dpdk.org (Postfix) with ESMTP id 1B03240040 for ; Mon, 8 Nov 2021 07:29:21 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d3qP3n5mhRdvCgJ2WHwBhEOOivJmF5X1gNXjDobbvm3KjskNlcM2B0zZgBQ4IZC3D+qJbooO75lmswqlzbV2Prl86ulMBnT+HEU/HC0rYsZj/C58QJ9B2IOKkV7lqpyNfabm0drzBu+BpjxPSoO5Fv4K/Q0Uil6+eAeE6MAAnMkAY0hLi/Bwssv/hcyMau6MfMjx5L549HMmxM//7PFqtGzYYodI6qUz/8xsO3WQNBv30vaUzFrwMNNf7Ekd4PZ9QrzVapQ72ZdZ/KcpBvCgfH7IuYXD98nAS7wWLZuGvvm4zL0bqUtYkwz6xzApKEokOX75tVPw7wh4AF/ntNo0sw== 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=+M/xyw6JG6IAZGkrWT0Sm76V4zp83sdUKxNd5G3WqFc=; b=e38tqqMQTrjDavdagaK9EUdjKoUf7zQEzlWEQIO4twLsrZl1/hhTF4GKcRns9+6BPc2aTM7maxaUfYDAyWjhCKjKfGPG5+82bBkTaoLGykhBoCxo2y0aGDP2pPChIkRVx65rDmFPeoWGyB+a0Fje03Dvswv2WKGSRFJZFu1/CxMvihbBtlqw8lEH3IuZ0BJEoHn0LJj3DfMLuvuxK03NUPHdJ3dowslJxt3wDflGIneDbfkalrJ9qNcaMCnPO15VormTyzA7o67Xp38BiREWjoJ6/A5khrfWuuHvn9gE52fDjiUIbHhneKYmIuth72DBYzVAnKFMbJYCLLe24ztlPQ== 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=+M/xyw6JG6IAZGkrWT0Sm76V4zp83sdUKxNd5G3WqFc=; b=lmRtRNvy4hsh+zEetM3Eo4BDRNsOwjPTioiP0Ux56CJz7lLsQpS6TMsOXBfMFoiWq+CYGD+SGzarxiDXlLi2tfPkoVGGrPde4GWrBkzYyz/g/TXarp5IJEJlHurwHOKiWWMhbg698XJZh+VH0GQOwJs76xozss0uUGpHy9XFywXGiEgDcsI5BD+aNotSba03sYtBspPmHRhzpUqvGzr/HV3HFtHCs+Flf8ThO2iaaXe8Nn/X6U3Mj+rzcTuUkcXz7WwSZEAiWnY2XL7s55ABgWNy2JsQAuPxneVYBN/f2ND7lK7qrzJ7C+YaabvJrqewLf3uvHkn2wXmnKgcVyz1Qg== Received: from DS7PR03CA0152.namprd03.prod.outlook.com (2603:10b6:5:3b2::7) by DM6PR12MB5517.namprd12.prod.outlook.com (2603:10b6:5:1be::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Mon, 8 Nov 2021 06:29:19 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::1c) by DS7PR03CA0152.outlook.office365.com (2603:10b6:5:3b2::7) 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:19 +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 DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) 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:18 +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:15 +0000 From: Ali Alnubani To: CC: , , , , Date: Mon, 8 Nov 2021 08:28:07 +0200 Message-ID: <20211108062815.7614-3-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: 51322935-84e8-41a1-dd12-08d9a2811809 X-MS-TrafficTypeDiagnostic: DM6PR12MB5517: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LydzFR6DafXq/9gbNFPBhFaLZB6pz6Pk1SrE87vGx9B3rE11nk+SNgXj/BAluUfl3SukMVCjJXLL4tuizn1GLpVDNcWmm/A3SPgjlb+z7+zKpdTsLk+CtrxSnrWFaDBQ/2PlbJTXG1jrVQvTKTi+NRjYYOjBfmHOG6jltaXKyike+OMz2KXPt1fjm7JAMbmkN3ymgrtLQQOWSlJ2ZZlCbpcR3El5LAz9vId8NneMekC8+oTL/dJZH+naUa4DxVnz2rNwD4FAoBqNc7r0969K24GekpFVldHvsBnoDz8mjblFTNCi/T1hnCZS6nPiOw5UQ68VZh5BSkvfsbVdzqQ4SH4gzu7/A97bDy+H1RkBynGXNd4cHcHImPJ3WJ6SHyD9ZjaWzyozr+Yw7+0NZz+4C1AcnnAzJyWb4Y3krFM/M6ZC0CbonQIdP6jzfHsX6zR/ciRd/gvRlRQDLZfy/FVLeHZe0ghbTGGIRdmbb8CaLLOPXles/O2+P0aQ5fN0iizZKQi603v2Cm8JiZYatQ3qY+bBHy/XXima8zKmO/FlG/GtL/qH7U2yrWl7HjOaYmF447A0ZJKzZ8DWuOVsva7nwHKnKxXD5D+JRJPt76APkFrwUSDaJS9j90t3Sk4oPqJpyi0Xq1K4boIY0IAfYo5ZZOVcfiexaScQqSs8gkxP6+Z1ko3lAdR6i3mewcRTnMAVzlZjurYLuPGD690Q8bmhmA== 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)(36840700001)(46966006)(6916009)(70206006)(16526019)(2906002)(86362001)(6666004)(36756003)(7696005)(5660300002)(83380400001)(47076005)(6286002)(186003)(2616005)(36906005)(1076003)(426003)(336012)(36860700001)(82310400003)(316002)(70586007)(8676002)(508600001)(26005)(356005)(55016002)(8936002)(54906003)(7636003)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 06:29:18.6197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51322935-84e8-41a1-dd12-08d9a2811809 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: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5517 Subject: [dpdk-ci] [PATCH v4 02/10] tools: match by tree URL instead of tree name 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" The tree URL has more information. It can be used to get the maintainer of a tree, and it includes the tree name anyway. Although we can construct the tree URL by prepending "git://dpdk.org/next/" to the trees that have "next-" in their name, and prepending "git://dpdk.org/" to anything else, it would be safer to read the URL from the MAINTAINERS file just in case new trees that don't follow this rule were added. Also try to use named capture groups as much as possible. Signed-off-by: Ali Alnubani --- tools/pw_maintainers_cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index a31f605..343e9f5 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -46,7 +46,8 @@ Or if you want to use inside other scripts: maintainers = Maintainers() patch_id = 52199 files = Diff.find_filenames(_git_pw.api_get('patches', patch_id)['diff']) - tree = maintainers.get_tree(files) + tree_url = maintainers.get_tree(files) + tree_name = tree_url.split('/')[-1] """ @@ -116,9 +117,9 @@ class Diff(object): class Maintainers(object): file_regex = r'F:\s(.*)' - tree_regex = r'T: git:\/\/dpdk\.org(?:\/next)*\/(.*)' + tree_regex = r'T: (?Pgit:\/\/dpdk\.org(?:\/next)*\/(?P.*))' section_regex = r'([^\n]*)\n-+.*?(?=([^\n]*\n-+)|\Z)' - subsection_regex = r'[^\n](?:(?!\n{{2}}).)*?^F: {}(?:(?!\n{{2}}).)*' + subsection_regex = r'[^\n](?:(?!\n{{2}}).)*?^{}: {}$(?:(?!\n{{2}}).)*' def __init__(self): with open(MAINTAINERS_FILE_PATH) as fd: @@ -151,8 +152,8 @@ class Maintainers(object): if _tree: tree_list.append(_tree) tree = self.get_common_denominator(tree_list) - if tree == '': - tree = 'dpdk' + if not tree: + tree = 'git://dpdk.org/dpdk' return tree def _get_tree(self, filename): @@ -180,7 +181,7 @@ class Maintainers(object): found_match = False # Find the block containing filename. - regex = self.subsection_regex.format(re.escape(matching_pattern)) + regex = self.subsection_regex.format('F', re.escape(matching_pattern)) subsection_match = re.findall( regex, self.maintainers_txt, @@ -191,7 +192,7 @@ class Maintainers(object): tree_match = re.search( self.tree_regex, subsection) if tree_match: - tree = tree_match.group(1) + tree = tree_match.group('url') self.matched[matching_pattern] = tree found_match = True @@ -204,7 +205,7 @@ class Maintainers(object): self.tree_regex, section.group(0).split('\n\n')[0]) if tree_match: - tree = tree_match.group(1) + tree = tree_match.group('url') self.matched[matching_pattern] = tree return tree @@ -228,8 +229,8 @@ class Maintainers(object): os.path.commonprefix(_tree_list).rstrip('-').replace( 'dpdk-next-net-virtio', 'dpdk-next-virtio') # There is no 'dpdk-next' named tree. - if common_prefix == 'dpdk-next': - common_prefix = 'dpdk' + if common_prefix.endswith('dpdk-next') or common_prefix.endswith('/'): + common_prefix = 'git://dpdk.org/dpdk' return common_prefix @@ -289,4 +290,4 @@ if __name__ == '__main__': files = [] for patch in patch_list: files += Diff.find_filenames(patch['diff']) - print(maintainers.get_tree(files)) + print(maintainers.get_tree(files).split('/')[-1]) -- 2.25.1