From 77818bcb005a617fbacf5ce23296a17b2dc03e20 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 9 Oct 2024 10:42:23 -0400 Subject: [PATCH] Add stash indicator to status --- CHANGELOG.md | 1 + src/mepo/command/status.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f69945c5..4c76e8b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Hidden option `--location` for mepo that returns the path to the mepo directory +- Added ability to print number of stashes in `mepo status` ### Changed diff --git a/src/mepo/command/status.py b/src/mepo/command/status.py index 36db38a5..ad51bb12 100644 --- a/src/mepo/command/status.py +++ b/src/mepo/command/status.py @@ -34,6 +34,7 @@ def run(args): def check_component_status(comp, ignore_permissions): + """Check the status of a single component""" git = GitRepository(comp.remote, comp.local) # Older mepo clones will not have ignore_submodules in comp, so @@ -54,21 +55,27 @@ def check_component_status(comp, ignore_permissions): # This command is to try and work with git tag oddities curr_ver = sanitize_version_string(orig_ver, curr_ver, git) + # We also want to see if there are any stashes in the component + num_stashes = len(git.list_stash().splitlines()) + return ( curr_ver, internal_state_branch_name, + num_stashes, git.check_status(ignore_permissions, _ignore_submodules), ) def print_status(allcomps, result, max_width, nocolor=False, hashes=False): + """Print the status of all components""" for index, comp in enumerate(allcomps): time.sleep(0.025) print_component_status(comp, result[index], max_width, nocolor, hashes) def print_component_status(comp, result, width, nocolor=False, hashes=False): - current_version, internal_state_branch_name, output = result + """Print the status of a single component""" + current_version, internal_state_branch_name, num_stashes, output = result if hashes: comp_path = _get_relative_path(comp.local) comp_hash = shellcmd.run( @@ -86,8 +93,13 @@ def print_component_status(comp, result, width, nocolor=False, hashes=False): width += len(colors.RED) + len(colors.RESET) else: component_name = comp.name - FMT0 = "{:<%s.%ss} | {: