From 8c69049fdcdd7e91e8ebfa35b4f3c998552ddb40 Mon Sep 17 00:00:00 2001 From: liuhao1024 Date: Mon, 13 Jul 2026 08:14:37 +0800 Subject: [PATCH] fix(cli): avoid unnecessary stash and show fetch progress in hermes update Two fixes for regressions after #3492: 1. Show git fetch progress (sent to stderr) instead of discarding it 2. Defer _stash_local_changes_if_needed to after commit_count > 0 check, avoiding pointless stash/restore cycles when the checkout is current Fixes #3523 --- hermes_cli/main.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index f10fef3fd958e..bdc08971db0c2 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -9615,6 +9615,11 @@ def _cmd_update_impl(args, gateway_mode: bool): print(f" {stderr.splitlines()[0]}") sys.exit(1) + # Show fetch progress (git sends progress to stderr) + if fetch_result.stderr.strip(): + for line in fetch_result.stderr.strip().splitlines(): + print(f" {line}") + # Get current branch (returns literal "HEAD" when detached) result = subprocess.run( git_cmd + ["rev-parse", "--abbrev-ref", "HEAD"], @@ -9672,13 +9677,7 @@ def _cmd_update_impl(args, gateway_mode: bool): print(f" {track_result.stderr.strip().splitlines()[0]}") sys.exit(1) else: - auto_stash_ref = _stash_local_changes_if_needed(git_cmd, PROJECT_ROOT) - - prompt_for_restore = ( - auto_stash_ref is not None - and not assume_yes - and (gateway_mode or (sys.stdin.isatty() and sys.stdout.isatty())) - ) + auto_stash_ref = None # Check if there are updates result = subprocess.run( @@ -9690,6 +9689,17 @@ def _cmd_update_impl(args, gateway_mode: bool): ) commit_count = int(result.stdout.strip()) + # Only stash when there are actual updates to pull (avoids unnecessary + # stash/restore cycle when the checkout is already up to date) + if auto_stash_ref is None and commit_count > 0: + auto_stash_ref = _stash_local_changes_if_needed(git_cmd, PROJECT_ROOT) + + prompt_for_restore = ( + auto_stash_ref is not None + and not assume_yes + and (gateway_mode or (sys.stdin.isatty() and sys.stdout.isatty())) + ) + if commit_count == 0: _invalidate_update_cache()