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 D2C8442672; Fri, 29 Sep 2023 15:17:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC6A7402AA; Fri, 29 Sep 2023 15:17:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E449840287 for ; Fri, 29 Sep 2023 15:17:24 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38TCPgVP005336; Fri, 29 Sep 2023 06:17:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=AZdN0qHBJznoHpMI0cPxc5MVyK7dTGD3IqSamYMdXwk=; b=gfd6bHlsoEjMHAy7pgYOwn+yA+EqnU8SIhN+xSgeln7iJHTloSd6CWUGe1YNQp6yOVF4 rPjUJhE+FXejdt3DFws5xfcMO9rCTubQQN79cZVeodkF8aHxhtnjwIZpwEfzSVGQpHfb suQyQ43wzIhPYUQOAMGRKxte/AEZdZ7FgdFQKbdDnRmNzfI0Yaw1TO+6T7/94FJgxjYA xBRe1nNPHSerkE30PHRNABBqIzh/LwIQz8+hCzZQH03YtAPpp9M9GL7psvzls1piKgfI nUBRW9w407MTuRrKuvFWZ5AfNKzf2uL3efXmeXa6xFr/uOQKeEgCHrLbnd37wKd8Ji2b Ag== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3tdxk08bcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 29 Sep 2023 06:17:23 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 29 Sep 2023 06:17:21 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 29 Sep 2023 06:17:21 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id 57DBE5B6923; Fri, 29 Sep 2023 06:17:19 -0700 (PDT) From: To: , , , , CC: , Pavan Nikhilesh Subject: [PATCH v2] pw_maintainers_cli: enhance ci tree selection Date: Fri, 29 Sep 2023 18:47:14 +0530 Message-ID: <20230929131714.12525-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230929083443.9925-1-pbhagavatula@marvell.com> References: <20230929083443.9925-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: NUI0rwCjfvqQnqmWXGZ5MhBTJJtljrCk X-Proofpoint-ORIG-GUID: NUI0rwCjfvqQnqmWXGZ5MhBTJJtljrCk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-29_11,2023-09-28_03,2023-05-22_02 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 From: Pavan Nikhilesh When longest prefix match doesnt find a suitable tree, remove the trees of files belonging to 'drivers/common' and check if there is any unique tree for the patchset. Signed-off-by: Pavan Nikhilesh --- v2 Chnages: - Find tree by removing 'drivers/common' instead of count based approach. tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index c7b5ba0..ef60df8 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -203,13 +203,15 @@ class Maintainers(object): """ Return a git tree that matches a list of files.""" tree_list = [] + file_tree_map = {} for _file in files: _tree = self._get_tree(_file) # Having no tree means that we accept those changes going through a # subtree (e.g. release notes). if _tree: tree_list.append(_tree) - tree = self.get_common_denominator(tree_list) + file_tree_map[_file] = _tree + tree = self.get_common_denominator(tree_list, file_tree_map) if not tree: tree = 'git://dpdk.org/dpdk' return tree @@ -268,7 +270,7 @@ class Maintainers(object): self.matched[matching_pattern] = tree return tree - def get_common_denominator(self, tree_list): + def get_common_denominator(self, tree_list, file_tree_map): """Finds a common tree by finding the longest common prefix. Examples for expected output: dpdk-next-virtio + dpdk = dpdk @@ -278,7 +280,6 @@ class Maintainers(object): """ # Make sure the list is unique. tree_list = list(set(tree_list)) - # Rename dpdk-next-virtio internally to match dpdk-next-net _tree_list = [ tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio') @@ -286,11 +287,31 @@ class Maintainers(object): common_prefix = \ os.path.commonprefix(_tree_list).rstrip('-').replace( 'dpdk-next-net-virtio', 'dpdk-next-virtio') - # There is no 'dpdk-next' named tree. - if common_prefix.endswith('dpdk-next') or common_prefix.endswith('/'): + # There is no 'dpdk-next' named tree, remove files that belong + # to 'drivers/common' and see if we find a tree. + if common_prefix.endswith('dpdk-next'): + common_prefix = self.get_filtered_tree(file_tree_map) + elif common_prefix.endswith('/'): common_prefix = 'git://dpdk.org/dpdk' return common_prefix + def get_common_files(self, files): + match_list = [] + for f in files: + if re.match(r"drivers\/common", f) is not None: + match_list.append(f) + return match_list + + def get_filtered_tree(self, file_tree_map): + # Get list of files that are in 'drivers/common' + common_list = self.get_common_files(file_tree_map.keys()) + for c in common_list: + file_tree_map.pop(c, None) + tree_list = list(set(file_tree_map.values())) + if len(tree_list) == 1: + return tree_list[0] + return None + if __name__ == '__main__': """Main procedure.""" -- 2.25.1