[edk2-devel] [edk2-staging/EdkRepo] [PATCH 3/4] EdkRepo: Add support for multiple manifest repostories to command completions

Ashley E Desimone posted 4 patches 5 years, 9 months ago
[edk2-devel] [edk2-staging/EdkRepo] [PATCH 3/4] EdkRepo: Add support for multiple manifest repostories to command completions
Posted by Ashley E Desimone 5 years, 9 months ago
Update the command completions for the checkout pin command to support
multiple manifest repositories. If a source manifest repository cannot
be found for the current workspace then no completions will be provided.

Signed-off-by: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
---
 edkrepo/command_completion_edkrepo.py | 48 +++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/edkrepo/command_completion_edkrepo.py b/edkrepo/command_completion_edkrepo.py
index 1220924..8a2c0e6 100644
--- a/edkrepo/command_completion_edkrepo.py
+++ b/edkrepo/command_completion_edkrepo.py
@@ -15,6 +15,9 @@ import traceback
 
 from edkrepo_manifest_parser.edk_manifest import ManifestXml
 from edkrepo.common.common_repo_functions import combinations_in_manifest
+from edkrepo.common.edkrepo_exception import EdkrepoManifestNotFoundException
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import find_source_manifest_repo
 from edkrepo.config import config_factory
 from edkrepo.config.config_factory import get_workspace_manifest
 
@@ -28,23 +31,36 @@ def current_combo(parsed_args, config):
 
 def checkout_pin(parsed_args, config):
     pins = []
-    manifest_directory = config['cfg_file'].manifest_repo_abs_local_path
     manifest = get_workspace_manifest()
-    pin_folder = os.path.normpath(os.path.join(manifest_directory, manifest.general_config.pin_path))
-    for dirpath, _, filenames in os.walk(pin_folder):
-        for file in filenames:
-            pin_file = os.path.join(dirpath, file)
-            # Capture error output from manifest parser stdout so it is hidden unless verbose is enabled
-            stdout = sys.stdout
-            sys.stdout = io.StringIO()
-            pin = ManifestXml(pin_file)
-            parse_output = sys.stdout.getvalue()
-            sys.stdout = stdout
-            if parsed_args.verbose and parse_output.strip() != '':
-                print('Pin {} Parsing Errors: {}\n'.format(file, parse_output.strip()))
-            if pin.project_info.codename == manifest.project_info.codename:
-                pins.append(file)
-    print(' '.join(pins))
+    manifest_directory = None
+    try:
+        source_manifest_repo = find_source_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], )
+        if source_manifest_repo:
+            cfg, user_cfg, conflicts = list_available_manifest_repos(config['cfg_file'], config['user_cfgFile'])
+            if source_manifest_repo in cfg:
+                manifest_directory = config['cfg_file'].manifest_repo_abs_path(source_manifest_repo)
+            elif source_manifest_repo in user_cfg:
+                manifest_directory = config['user_cfg_file'].manifest_repo_abs_path(source_manifest_repo)
+            else:
+                manifest_directory = None
+    except EdkrepoManifestNotFoundException:
+        manifest_directory = None
+    if manifest_directory:
+        pin_folder = os.path.normpath(os.path.join(manifest_directory, manifest.general_config.pin_path))
+        for dirpath, _, filenames in os.walk(pin_folder):
+            for file in filenames:
+                pin_file = os.path.join(dirpath, file)
+                # Capture error output from manifest parser stdout so it is hidden unless verbose is enabled
+                stdout = sys.stdout
+                sys.stdout = io.StringIO()
+                pin = ManifestXml(pin_file)
+                parse_output = sys.stdout.getvalue()
+                sys.stdout = stdout
+                if parsed_args.verbose and parse_output.strip() != '':
+                    print('Pin {} Parsing Errors: {}\n'.format(file, parse_output.strip()))
+                if pin.project_info.codename == manifest.project_info.codename:
+                    pins.append(file)
+        print(' '.join(pins))
 
 # To add command completions for a new command, add an entry to this dictionary.
 command_completions = {
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59021): https://edk2.groups.io/g/devel/message/59021
Mute This Topic: https://groups.io/mt/74126916/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-