fix: invalidate update cache for all profiles, not just current

hermes update only cleared .update_check for the active HERMES_HOME,
leaving other profiles showing stale 'N commits behind' in their banner.

Now _invalidate_update_cache() iterates over ~/.hermes/ (default) plus
every directory under ~/.hermes/profiles/ to clear all caches. The git
repo is shared across profiles so a single update brings them all current.

Reported by SteveSkedasticity on Discord.
This commit is contained in:
Teknium 2026-04-02 00:48:56 -07:00
parent e4db72ef39
commit 835defe074
No known key found for this signature in database
2 changed files with 61 additions and 10 deletions

View file

@ -133,3 +133,41 @@ def test_get_update_result_timeout():
# Should have waited ~0.1s and returned None
assert result is None
assert elapsed < 0.5
def test_invalidate_update_cache_clears_all_profiles(tmp_path):
"""_invalidate_update_cache() should delete .update_check from ALL profiles."""
from hermes_cli.main import _invalidate_update_cache
# Build a fake ~/.hermes with default + two named profiles
default_home = tmp_path / ".hermes"
default_home.mkdir()
(default_home / ".update_check").write_text('{"ts":1,"behind":50}')
profiles_root = default_home / "profiles"
for name in ("ops", "dev"):
p = profiles_root / name
p.mkdir(parents=True)
(p / ".update_check").write_text('{"ts":1,"behind":50}')
with patch.object(Path, "home", return_value=tmp_path):
_invalidate_update_cache()
# All three caches should be gone
assert not (default_home / ".update_check").exists(), "default profile cache not cleared"
assert not (profiles_root / "ops" / ".update_check").exists(), "ops profile cache not cleared"
assert not (profiles_root / "dev" / ".update_check").exists(), "dev profile cache not cleared"
def test_invalidate_update_cache_no_profiles_dir(tmp_path):
"""Works fine when no profiles directory exists (single-profile setup)."""
from hermes_cli.main import _invalidate_update_cache
default_home = tmp_path / ".hermes"
default_home.mkdir()
(default_home / ".update_check").write_text('{"ts":1,"behind":5}')
with patch.object(Path, "home", return_value=tmp_path):
_invalidate_update_cache()
assert not (default_home / ".update_check").exists()