From f1af61354e788132fe23cdbc09a29c73faf6685b Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Mon, 27 Jul 2026 20:11:11 -0500 Subject: [PATCH] fix(banner): scope the startup update fetch to main The background update check ran a bare `git fetch origin`, which walks whatever refspec the checkout has. That is cheap today only because installer clones are pinned to main; on any checkout that can see the repo's ~1400 branches it becomes a multi-hundred-MB pull behind a 10s timeout, on every launch. Naming the branch keeps it to one ref. --- hermes_cli/banner.py | 6 +++++- tests/hermes_cli/test_update_check.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hermes_cli/banner.py b/hermes_cli/banner.py index 08e2ceeb1fa..4baf73b2cfc 100644 --- a/hermes_cli/banner.py +++ b/hermes_cli/banner.py @@ -219,7 +219,11 @@ def _check_via_local_git(repo_dir: Path) -> Optional[int]: is_shallow = shallow == "true" try: - fetch_args = ["git", "fetch", "origin"] + # Name the branch. A bare `git fetch origin` walks the configured + # refspec; on a checkout that can see all of this repo's branches + # that is hundreds of MB, behind a 10s timeout, on every startup. + # Naming main keeps it to one ref whatever remote.origin.fetch says. + fetch_args = ["git", "fetch", "origin", "main"] if is_shallow: fetch_args += ["--depth", "1"] fetch_args.append("--quiet") diff --git a/tests/hermes_cli/test_update_check.py b/tests/hermes_cli/test_update_check.py index 48a8da3045c..5b8a843b344 100644 --- a/tests/hermes_cli/test_update_check.py +++ b/tests/hermes_cli/test_update_check.py @@ -125,7 +125,7 @@ def test_check_for_updates_official_ssh_origin_uses_https_probe(tmp_path): result = banner._check_via_local_git(repo_dir) assert result == 1 - assert ["git", "fetch", "origin", "--quiet"] not in calls + assert not any(cmd[:2] == ["git", "fetch"] for cmd in calls) def test_check_via_local_git_shallow_clone_behind_reports_no_count(tmp_path): @@ -165,8 +165,10 @@ def test_check_via_local_git_shallow_clone_behind_reports_no_count(tmp_path): result = banner._check_via_local_git(repo_dir) assert result == banner.UPDATE_AVAILABLE_NO_COUNT - # The shallow fetch must preserve the boundary (--depth 1), not unshallow. - assert ["git", "fetch", "origin", "--depth", "1", "--quiet"] in calls + # The shallow fetch must preserve the boundary (--depth 1), not unshallow, + # and must name main so a checkout that can see every branch doesn't pull + # them all on startup. + assert ["git", "fetch", "origin", "main", "--depth", "1", "--quiet"] in calls def test_check_via_local_git_shallow_clone_up_to_date(tmp_path):