mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
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.
This commit is contained in:
parent
d83e858507
commit
f1af61354e
2 changed files with 10 additions and 4 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue