Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion hermes_cli/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,15 @@ def _check_via_local_git(repo_dir: Path) -> Optional[int]:
is_shallow = shallow == "true"

try:
fetch_args = ["git", "fetch", "origin"]
# Scope the fetch to the one branch the behind-count compares against.
# An unscoped ``git fetch origin`` transfers every remote head (~1,400
# on this repo — measured 3.0 s vs 0.55 s scoped) and can burn the full
# 10 s timeout on slow links. ``cmd_update`` already scopes its fetch
# for the same reason. Modern git updates the ``origin/main`` tracking
# ref on a scoped fetch, so the ``HEAD..origin/main`` count below is
# unaffected; the shallow path compares against FETCH_HEAD, which a
# scoped fetch also updates.
fetch_args = ["git", "fetch", "origin", "main"]
if is_shallow:
fetch_args += ["--depth", "1"]
fetch_args.append("--quiet")
Expand Down
5 changes: 3 additions & 2 deletions tests/hermes_cli/test_update_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ def fake_run(cmd, **kwargs):
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 stay scoped to main (unscoped fetches transfer ~1,400 heads).
assert ["git", "fetch", "origin", "main", "--depth", "1", "--quiet"] in calls


def test_check_via_local_git_shallow_clone_up_to_date(tmp_path):
Expand Down
Loading