Reviewed-by: Puja Pandya <puja.pan...@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Desimone, 
Nathaniel L
Sent: Monday, December 9, 2019 4:02 PM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desim...@intel.com>; Pandya, Puja 
<puja.pan...@intel.com>; Desimone, Nathaniel L <nathaniel.l.desim...@intel.com>
Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: EdkRepo fails to 
run in detached HEAD mode

If the current working directory is a git repo, then the EdkRepo entrypoint 
will fail to execute. This is caused by the command_factory being overzealous 
while searching for commands and constructing GitPython objects and searching 
those objects for EdkRepo commands.

Cc: Ashley E Desimone <ashley.e.desim...@intel.com>
Cc: Puja Pandya <puja.pan...@intel.com>
Signed-off-by: Nathaniel L Desimone <nathaniel.l.desim...@intel.com>
---
 edkrepo/commands/command_factory.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/edkrepo/commands/command_factory.py 
b/edkrepo/commands/command_factory.py
index 9f2e923..b607724 100644
--- a/edkrepo/commands/command_factory.py
+++ b/edkrepo/commands/command_factory.py
@@ -61,9 +61,16 @@ def get_commands():
             if module == '__init__.py' or os.path.splitext(module)[1] != '.py':
                 continue
             mod = importlib.import_module('{}.{}'.format(cmd_dir[0], 
os.path.splitext(module)[0]))
+            mod_path = 
+ os.path.normcase(os.path.normpath(inspect.getfile(mod)))
             classes = inspect.getmembers(mod, predicate=inspect.isclass)
             for cls in classes:
-                if _is_command(cls[1]):
+                in_same_module = False
+                try:
+                    if mod_path == 
os.path.normcase(os.path.normpath(inspect.getfile(cls[1]))):
+                        in_same_module = True
+                except TypeError:
+                    pass
+                if in_same_module and _is_command(cls[1]):
                     if cmd_dir[0] == pref_cmd_pkg:
                         pref_commands.update([(cls[0], cls[1])])
                     else:
--
2.20.1





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

View/Reply Online (#52258): https://edk2.groups.io/g/devel/message/52258
Mute This Topic: https://groups.io/mt/67921384/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to