From 53bdef57751a7658bbe4b962d6bb8d6c739ab97f Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 28 May 2026 01:29:30 +0530 Subject: [PATCH] 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. --- tests/hermes_cli/test_cmd_update.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/hermes_cli/test_cmd_update.py b/tests/hermes_cli/test_cmd_update.py index e4cf849f261..6610bfc810e 100644 --- a/tests/hermes_cli/test_cmd_update.py +++ b/tests/hermes_cli/test_cmd_update.py @@ -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(