test(cli): regression test for hermes update fork upstream sync (#26172)

Asserts that when hermes update runs on a fork whose local HEAD matches
origin/main but commit_count == 0, the early-return path still consults
_sync_with_upstream_if_needed() before printing "Already up to date!".

Locks in the fix from the parent commit so the upstream-sync call cannot
silently regress out of the commit_count == 0 branch.
This commit is contained in:
kshitijk4poor 2026-05-28 01:29:30 +05:30 committed by kshitij
parent 6f2a2f157f
commit 53bdef5775

View file

@ -106,6 +106,33 @@ class TestCmdUpdateBranchFallback:
pull_cmds = [c for c in commands if "pull" in c]
assert len(pull_cmds) == 0
@patch("shutil.which", return_value=None)
@patch("subprocess.run")
def test_update_on_fork_checks_upstream_when_origin_up_to_date(
self, mock_run, _mock_which, mock_args, capsys
):
"""Regression for issue #26172: forks whose local HEAD already matches
origin/main must still consult upstream/main before printing
"Already up to date!" otherwise a fork that's caught up to its own
origin but behind NousResearch/hermes-agent silently misses updates.
"""
from hermes_cli import main as hm
mock_run.side_effect = _make_run_side_effect(
branch="main", verify_ok=True, commit_count="0"
)
with patch.object(
hm,
"_get_origin_url",
return_value="https://github.com/example/hermes-agent.git",
), patch.object(hm, "_sync_with_upstream_if_needed") as sync_mock:
cmd_update(mock_args)
sync_mock.assert_called_once_with(["git"], PROJECT_ROOT)
captured = capsys.readouterr()
assert "Already up to date!" in captured.out
@patch("shutil.which")
@patch("subprocess.run")
def test_update_refreshes_repo_and_tui_node_dependencies(