[PATCH v2] pw_maintainers_cli: enhance ci tree selection

Aaron Conole aconole at redhat.com
Thu Oct 12 14:59:05 CEST 2023


<pbhagavatula at marvell.com> writes:

> From: Pavan Nikhilesh <pbhagavatula at marvell.com>
>
> 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 <pbhagavatula at marvell.com>
> ---
>  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')

Any reason why this whitespace is dropped here?  Otherwise, the patch
looks okay - but I don't think this line should be dropped.

If you agree, I can correct when I merge it.

> @@ -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



More information about the ci mailing list