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 9E50EA0C43 for ; Mon, 18 Oct 2021 09:46:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9937040DDE; Mon, 18 Oct 2021 09:46:16 +0200 (CEST) Received: from AZHDRRW-EX02.NVIDIA.COM (azhdrrw-ex02.nvidia.com [20.64.145.131]) by mails.dpdk.org (Postfix) with ESMTP id 1329C40683 for ; Mon, 18 Oct 2021 09:46:15 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.107) by mxs.oss.nvidia.com (10.13.234.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Mon, 18 Oct 2021 00:46:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YAilBYKFqnep4r4UN8t784AHqrRZplKDtH2LyPLRQgyqhH1Sme9TAHr0Gh7sRHlwMhkWxPs2EEeKnqw+1w837jDg/G3EPDPZDa+yU9vRbiF523Mf2NGZfHwn1et1hTdO8x6CPtNmq/NHqPoS3lwgBlV0ckoAobCRGNPp16hMG3DsWP3sgAvlSL3QP1Yq+5OIdxqwLUuj29LDIYjgIGcDCIiZCrPumj5BUHNe0ZSTV3SqW2GsimdCiut7P+1vRV6lcRfP4IMWlE/FcuAuEl55+u3KY8omRs87HZoMxj3N5HrOQr41t4EcakrPl6wwdNyYHFZGeSGmQjUfA/L8+LuFzg== 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=ho25w8L/cRPeF3SU9FLdvQsE7Ywq5xTOT9vu/lETIMau/o799YhfgOpyfwJsy+/U8JuFlnR2RUqL7cyIS6QhHE37GKbjncHFvF9IvcxuXzPw9IsIML8EFSrBVvVgjPOfP6OKX5EN2+0s0v7LuKVgZOK3XuMEQM9JN3OBNbFtENOTd2pEz0jeiiuQ8gjggg7LYkxgLlWqqTg4/96OTG1rHCU9Cg5rI20W7naZLPwGlYbO5Ut+AoqTk2j9RPIL8Bw3PGWMLAJ7a/SQNgedpPLj/+EmoZLVO6a84isk5bW13i+e/3dmp4a7kYbwZdhcq5x8+rBAYTpFVjjTzGduqlf0Sg== 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=Qe9mabjPQQHEFiSWWvhDKIvTVJUvOcbFAW+/F59HmuNvlq4j0njG5+ZGn9TPWkAkp8uXwZ81EYIJldMzc3vJ/WuvRIfBuIbSiuiFPqhesl3hlT/U95ZqSIM9pXajcdiIjr8FgozrYINZZcG8Jnp33lRYglbporzJZ7ACVEi1NxstIT8LCN9CRezXLDLPDzm3AJP3rG8Aj00yPoHFJcGlJfUVoZ/nGM3QIkmrBffJdOBGG+xb1BAoR6duPbNEO0762IbsUwVjkuIXsTpBVgmrJE6p/mli7cZwfgZcIVXL2bUDz9jiUOfr/xnntijAmku0dVlk3na6IVkXxR0JZ1Zmow== Received: from MWHPR14CA0054.namprd14.prod.outlook.com (2603:10b6:300:81::16) by BL0PR12MB2529.namprd12.prod.outlook.com (2603:10b6:207:4e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Mon, 18 Oct 2021 07:46:11 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::a5) by MWHPR14CA0054.outlook.office365.com (2603:10b6:300:81::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 07:46:11 +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 CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 07:46:10 +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, 18 Oct 2021 07:46:07 +0000 From: Ali Alnubani To: CC: , , , , Date: Mon, 18 Oct 2021 10:44:52 +0300 Message-ID: <20211018074500.16199-3-alialnu@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018074500.16199-1-alialnu@nvidia.com> References: <20211018074500.16199-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: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85fc2e5f-278e-4620-2124-08d9920b5a87 X-MS-TrafficTypeDiagnostic: BL0PR12MB2529: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True 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: BpMhVVqPSSpzyH/aOze1WWf9JY6bCN+jLBTf2WaoNmvL2K4ouLU9/N6TNtxL6AivRroYtlUp2nMO31jSRAzkevbuoc+hAF7BQ/H3C7E2Vm6XhGkZP0JX2nzErCQk8FplxcTLnnc/gqMp7Qwf4S+zh2zrVSxbmpAkI1yx42kRIBvvasonTYNSiPW1rLKvlkOHqX/eWpYzW7x0fbSKMhNd0CDscTBxN7Pia2yT5TVUvot6VaYAhOPY1xOZGgqkKfQp53GUiEpAGBBTY6R1QboAsHgmtYX+N/hYaWI6zlR2t3fbnbc4j1YfrdHWsplur7feyqbcuCMMmkMsjTZIkyPSoQqNKMCK6rVZ7SSauIc1CV/8oJ6IXLR6Z5iasuHS9DyLCRBR81SIeie+kzys/JWBeFgahdVxu5VN6/ZZSP+hstd4ArDXQE+X6OsHKqFf8mCbOLAD6v5E7KBmTFNYsxliI9eOYdEMxju3S55HUVvSIGGRXCYWZtm6xVFh0eMSIss+7yW9V7w55PGF7SZurciBXlNpppNbtySZ9Umq9LIL+fdyODLLWV/oQnagHqRop+cKKRPZUWPCxsyzEneRGll0ayuHXv94xBdhZYIUcXK2tMGuSApUnRqwtbE6Splhd1pxi6wKYo7Zr7CHl4ht23BBS8UfNljr0gdyEZx706+e/4C4DFuSFYAjxHeraco9u7dTHlMwoDCtLQc/cNLF7PIBPg== 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)(2906002)(16526019)(86362001)(36756003)(82310400003)(8676002)(7636003)(6286002)(336012)(426003)(2616005)(508600001)(6916009)(54906003)(107886003)(7696005)(55016002)(356005)(26005)(36860700001)(316002)(8936002)(5660300002)(4326008)(83380400001)(6666004)(70586007)(70206006)(186003)(47076005)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2021 07:46:10.9547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85fc2e5f-278e-4620-2124-08d9920b5a87 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2529 Subject: [dpdk-ci] [PATCH v3 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