The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): fetch a stable release's own tag with its commit
Teknium0e3aefb8c119
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex 764bd4d69b8..6ebf3b914fa 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -1906,7 +1906,7 @@ def _cmd_update_impl(args, gateway_mode: bool):# Forward-only default: the checkout already contains the release; nothing to fetch.fetch_args = Noneelif release_sha:- fetch_args = ["fetch", "--no-tags", "origin", target_ref]+ fetch_args = _check.release_fetch_args(target_ref, completion_request)else:fetch_args = ["fetch", "origin", _check.tracking_refspec("origin", branch)]from hermes_cli.gitlock import fetch_with_partial_clone_recovery, is_partial_clone_pack_objects_crashdiff --git a/hermes_cli/update_cmd_check.py b/hermes_cli/update_cmd_check.pyindex f04b962b676..2ca2372f671 100644--- a/hermes_cli/update_cmd_check.py+++ b/hermes_cli/update_cmd_check.py@@ -263,12 +263,26 @@ def select_apply_target(args, branch: str, request: dict, *, git_cmd, stop) -> tif target.commit:print(f"→ {'Release' if target.ahead else 'Latest release'}: {target.label}")request["expected_sha"] = target.commit+ if target.channel == "stable" and target.version and not target.ahead:+ request["release_tag"] = f"v{target.version}" # verified on origin by the resolverreturn target.commit, target.commit, target.ahead, target.repositoryassert target.branch is not None # a SourceTarget without a commit names its branchrequest["branch"] = target.branchreturn f"origin/{target.branch}", None, False, target.repository+def release_fetch_args(target_ref: str, request: dict) -> list[str]:+ """Fetch a pinned release commit together with its own release tag.++ The checkout's version is the newest release tag merged into HEAD (version_info), so a+ tagless fetch moved HEAD to vX.Y.Z while every reader -- /health, the install stamp, the+ receipt, About -- still named the previous release (#143656). Only that one tag: other+ tags would drag their histories into a shallow checkout.+ """+ tag = request.get("release_tag")+ return ["fetch", "--no-tags", "origin", target_ref, *([f"+refs/tags/{tag}:refs/tags/{tag}"] if tag else [])]++def hold_channel_release_behind_runtime(git_cmd, target_ref: str, channel: str) -> str | None:"""HEAD's sha when the channel's release predates the gateway runtime these stores use, else None.diff --git a/tests/hermes_cli/test_update_release_tag_fetch.py b/tests/hermes_cli/test_update_release_tag_fetch.pynew file mode 100644index 00000000000..59f32a5bae1--- /dev/null+++ b/tests/hermes_cli/test_update_release_tag_fetch.py@@ -0,0 +1,48 @@+"""A stable update names the checkout by the release it moved to (#143656).++The checkout's version is the newest release tag merged into HEAD. A stable update+fetched the release commit with ``--no-tags``, so HEAD sat on vX.Y.Z while /health,+the install stamp and the receipt still named the previous release.+"""++import subprocess+from types import SimpleNamespace++from hermes_cli import update_cmd_check+from hermes_cli.source_releases import SourceTarget+from hermes_cli.version_info import _git_version_info+++def _git(cwd, *args):+ return subprocess.run(["git", "-c", "user.name=t", "-c", "[email protected]", *args],+ cwd=cwd, check=True, capture_output=True, text=True).stdout.strip()+++def test_stable_update_fetch_brings_the_release_tag(tmp_path, monkeypatch):+ origin, checkout = tmp_path / "origin", tmp_path / "checkout"+ origin.mkdir()+ _git(origin, "init", "-q", "-b", "main")+ (origin / "f").write_text("1")+ _git(origin, "add", "f")+ _git(origin, "commit", "-qm", "one")+ _git(origin, "tag", "v0.22.2")+ _git(tmp_path, "clone", "-q", str(origin), str(checkout))+ (origin / "f").write_text("2")+ _git(origin, "commit", "-qam", "two")+ _git(origin, "tag", "v0.22.3")+ release = _git(origin, "rev-parse", "HEAD")++ monkeypatch.setattr(update_cmd_check, "_uc", lambda: SimpleNamespace(+ _m=lambda: SimpleNamespace(PROJECT_ROOT=checkout), _update_run_channel=lambda _a: "stable"))+ monkeypatch.setattr("hermes_cli.source_releases.resolve_source_target", lambda *a, **k: SourceTarget(+ "stable", "stable", "NousResearch/hermes-agent", commit=release, version="0.22.3"))+ monkeypatch.setattr("hermes_cli.config.require_readable_config_before_write", lambda _p: {})+ request = {"home": str(tmp_path)}+ target_ref, _sha, _is_head, _repo = update_cmd_check.select_apply_target(+ SimpleNamespace(branch=None), "main", request, git_cmd=["git"], stop=lambda: None)++ _git(checkout, *update_cmd_check.release_fetch_args(target_ref, request))+ _git(checkout, "merge", "-q", "--ff-only", release)++ info = _git_version_info(checkout)+ assert (info.commit, info.base_version, info.display_version) == (release, "0.22.3", "0.22.3")