Skip to content

fix(cli): avoid unnecessary stash and show fetch progress in hermes update - #20112

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/issue-3523-update-stash-and-fetch-output
Open

fix(cli): avoid unnecessary stash and show fetch progress in hermes update#20112
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/issue-3523-update-stash-and-fetch-output

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented May 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes two regressions in hermes update introduced after #3492:

  1. Silent git fetch output — fetch progress (sent to stderr by git) was silently discarded on success, leaving the user staring at a blank screen during network operations.
  2. Unnecessary stash cycles — the update command stashed local changes before checking whether any new commits existed upstream. When the checkout was already up to date, this caused a pointless stash → check → restore cycle, printing misleading "preserving stash" messages.

Root Cause

In _cmd_update_impl, the stash was called unconditionally at the top of the "already on target branch" path, before the rev-list --count check that determines whether updates exist. This meant even hermes update on a clean checkout with no upstream changes would stash and immediately restore.

Fix

  1. Print fetch_result.stderr lines after a successful fetch so the user sees progress.
  2. Defer _stash_local_changes_if_needed to after the commit_count > 0 check, so the stash is only created when there are actual commits to pull.

This is a rebased version of the original PR — only the stash/fetch fix is included.

Related Issue

Fixes #3523

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • hermes_cli/main.py: Added fetch progress display after successful git fetch
  • hermes_cli/main.py: Moved _stash_local_changes_if_needed call to after the commit_count > 0 check in the same-branch path

How to Test

  1. Run python3 -m pytest tests/hermes_cli/test_update_autostash.py -q — should pass (33 tests)
  2. Run hermes update on a checkout that is already up to date — should NOT print any stash messages
  3. Run hermes update when updates are available — should show fetch progress lines, then stash if needed
  4. Observed result: All 33 autostash tests pass

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels May 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Fixes #3523 — addresses the unnecessary stash and silent fetch regressions from #3492.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Fixes #3523 — addresses the unnecessary stash and silent fetch regressions from #3492.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two regressions in hermes update introduced by #3492: (1) an unnecessary stash/restore cycle (and confusing prompt) when running on main with no updates, and (2) git fetch progress output being silently swallowed by capture_output=True.

Changes:

  • Defer _stash_local_changes_if_needed() on the main-branch path until after commit_count is computed, so stashing only happens when there are actual updates to pull.
  • After a successful git fetch, print captured stderr lines so the user sees git's progress messages.
  • Add three regression tests in test_update_autostash.py covering both fixes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
hermes_cli/main.py Moves main-branch stash call after commit-count check; prints fetch stderr after success.
tests/hermes_cli/test_update_autostash.py Adds 3 regression tests for no-stash on already-up-to-date, stash on updates, and visible fetch progress.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating two real hermes update regressions: current main still captures successful fetch stderr at hermes_cli/main.py:9570-9575 and stashes before the same-branch count check at hermes_cli/main.py:9650-9668.

Problems

  • The new same-branch auto_stash_ref = None path removes protection from fork updates where origin/main is current but upstream is ahead. Current main invokes _sync_with_upstream_if_needed() before the no-update return (hermes_cli/main.py:9671-9673), and that helper can run git pull --ff-only upstream main (hermes_cli/main.py:6879-6884). Dirty edits that overlap upstream changes can therefore block this update path instead of being safely stashed.
  • Fetch stderr is still captured, then printed after fetch completion. This makes progress visible eventually but not live.

Suggested changes

  • Keep autostash protection for a possible upstream fast-forward, and add a dirty-fork/upstream-ahead regression test.
  • Stream fetch progress while preserving the existing failure diagnostics.

Automated hermes-sweeper review.

Comment thread hermes_cli/main.py Outdated
and not assume_yes
and (gateway_mode or (sys.stdin.isatty() and sys.stdout.isatty()))
)
auto_stash_ref = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the pre-count stash for fork checkouts too: when origin/main is current but upstream/main is ahead, the no-update branch invokes _sync_with_upstream_if_needed(), which can run git pull --ff-only upstream main. Preserve a stash before that possible fast-forward or add a prior upstream availability check and stash only when it reports an update.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
…pdate

Two fixes for regressions after NousResearch#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 NousResearch#3523
@liuhao1024
liuhao1024 force-pushed the fix/issue-3523-update-stash-and-fetch-output branch from 77d657e to 8c69049 Compare July 13, 2026 00:14
@teknium1 teknium1 added the area/install-update Installer, updater, packaging, wheels, doctor label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install-update Installer, updater, packaging, wheels, doctor comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hermes update regressions after #3492 — silent git output and unnecessary stashes

4 participants