[dpdk-ci] [PATCH 3/9] tools: update script usage

Ali Alnubani alialnu at oss.nvidia.com
Mon Sep 6 17:45:31 CEST 2021


The resource type (whether it's a patch or a series) is now
specified by the new argument --type.
Both commands: list_trees_for_patch & list_trees_for_series
are replaced by the command: list_trees, and the type must
be always set.

This makes adding more operations require less arguments
and easier.

Signed-off-by: Ali Alnubani <alialnu at nvidia.com>
---
 tools/maintainers.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/tools/maintainers.py b/tools/maintainers.py
index 22933d5..e4ea317 100755
--- a/tools/maintainers.py
+++ b/tools/maintainers.py
@@ -31,8 +31,8 @@ variables PW_{SERVER,PROJECT,TOKEN} should be set. If not, the script will try
 to load the git configurations pw.{server,project,token}.
 
 Example usage:
-    ./maintainers.py --command list_trees_for_series 2054
-    ./maintainers.py --command list_trees_for_patch 2054
+    ./maintainers.py --command list_trees --type series 2054
+    ./maintainers.py --command list_trees --type patch 2054
 
 Or if you want to use inside other scripts:
 
@@ -243,9 +243,14 @@ if __name__ == '__main__':
     options_parser.add_argument(
             '--command',
             choices=(
-                'list_trees_for_patch',
-                'list_trees_for_series'),
+                'list_trees'),
             required=True, help='Command to perform')
+    options_parser.add_argument(
+            '--type',
+            choices=(
+                'patch',
+                'series'),
+            required=True, help='Resource type.')
 
     git_pw_conf_parser.add_argument(
             '--pw_server', type=str,
@@ -268,6 +273,7 @@ if __name__ == '__main__':
     args = parser.parse_args()
 
     command = args.command
+    resource_type = args.type
     _id = args.id
 
     # Pass the needed configurations to git-pw.
@@ -279,9 +285,9 @@ if __name__ == '__main__':
     maintainers = Maintainers()
 
     patch_list = []
-    if command == 'list_trees_for_patch':
+    if resource_type == 'patch':
         patch_list.append(_git_pw.api_get('patches', _id))
-    elif command == 'list_trees_for_series':
+    else:
         series = _git_pw.api_get('series', _id)
         patch_list = [
                 _git_pw.api_get('patches', patch['id'])
@@ -290,4 +296,8 @@ if __name__ == '__main__':
     files = []
     for patch in patch_list:
         files += Diff.find_filenames(patch['diff'])
-    print(maintainers.get_tree(files).split('/')[-1])
+
+    tree = maintainers.get_tree(files)
+
+    if command == 'list_trees':
+        print(tree.split('/')[-1])
-- 
2.25.1



More information about the ci mailing list