refactor(checkpoints): reuse _store_has_head in the footprint notice

The notice re-checked store/HEAD inline; tools/checkpoint_manager.py already
exposes _store_has_head() for exactly that. Also pin the notice test to
"across 1 project(s)" so a count of 11 cannot satisfy it.
This commit is contained in:
kshitijk4poor authored and Teknium committed 2026-10-10 13:29:32 -07:00
1 parent e5d94d9537
commit b406d25f24
2 files changed
+4 -3

No files matched your search

@@ -35,7 +35,7 @@ def test_notice_only_when_enabled_and_over_cap(tmp_path, monkeypatch):
monkeypatch.setattr("tools.checkpoint_maintenance._run_git", unexpected_git)
notice = checkpoint_footprint_notice()
assert notice
assert "1 project(s)" in notice
assert "across 1 project(s)" in notice
_write_config(enabled=True, cap_mb=500) # under the cap: no nag for a healthy store
assert checkpoint_footprint_notice() is None
+3 -2
View File
@@ -11,7 +11,8 @@ from utils import rmtree_readonly
from tools.checkpoint_manager import (
_GIT_TIMEOUT, _LEGACY_PREFIX, _PRUNE_MARKER_NAME, _REFS_PREFIX, _STORE_DIRNAME,
_dir_size_bytes, _index_path, _list_projects, _pre_v2_shadow_repos,
_project_meta_path, _ref_name, _resolve_checkpoint_base, _run_git, _store_path,
_project_meta_path, _ref_name, _resolve_checkpoint_base, _run_git, _store_has_head,
_store_path,
)
logger = logging.getLogger(__name__)
@@ -461,7 +462,7 @@ def checkpoint_footprint_notice() -> Optional[str]:
return None
# The notice needs no commit counts: full status runs Git for every project.
store = _store_path(base)
project_count = len(_list_projects(store)) if (store / "HEAD").exists() else 0
project_count = len(_list_projects(store)) if _store_has_head(store) else 0
from hermes_cli.sizefmt import format_bytes
return (f"Filesystem checkpoints (/rollback) are on: {format_bytes(size)} across "
f"{project_count} project(s), above the {cap_mb} MB cap (one snapshot per project is "