summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-05 11:45:02 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-05 11:45:02 +0000
commit203623a34055c41aed529d50c24fb4a99714ccb7 (patch)
tree123de3f67adfeeba414e9d07b76d0be65e986558
parent10dcca207438f284e21e5010de6ae0f766a0fa83 (diff)
downloadmorph-203623a34055c41aed529d50c24fb4a99714ccb7.tar.gz
Fix `morph help-extensions` run outside a workspace
This command would use the sysbranchdir.open_from_within() function call to search for a system branch, which traverses all subdirectories looking for a directory. This is useful behaviour, but if the user ran `morph help-extensions` in / it'd traverse their whole filesystem before returning, which is stupid. This change means it only does the traverse if it already detected a workspace.
-rw-r--r--morphlib/extensions.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/morphlib/extensions.py b/morphlib/extensions.py
index b270d304..051a54a7 100644
--- a/morphlib/extensions.py
+++ b/morphlib/extensions.py
@@ -38,6 +38,7 @@ class ExtensionNotExecutableError(ExtensionError):
pass
def _get_root_repo():
+ workspace = morphlib.workspace.open('.')
system_branch = morphlib.sysbranchdir.open_from_within('.')
root_repo_dir = morphlib.gitdir.GitDirectory(
system_branch.get_git_directory_name(
@@ -77,7 +78,8 @@ def _list_extensions(kind):
try:
repo_extension_filenames = \
_list_repo_extension_filenames(kind)
- except (sysbranchdir.NotInSystemBranch):
+ except (morphlib.workspace.NotInWorkspace,
+ sysbranchdir.NotInSystemBranch):
# Squash this and just return no system branch extensions
pass
morph_extension_filenames = _list_morph_extension_filenames(kind)