Skip to content

The agent that grows with you

fix(update): a tags-only release-history refresh gives up after 30s, not 15 minutes

kshitijk4poor0fbefc8c2863
diff --git a/hermes_cli/gitlock.py b/hermes_cli/gitlock.py
index b147715d453..983251ff99c 100644
--- a/hermes_cli/gitlock.py
+++ b/hermes_cli/gitlock.py
@@ -652,6 +652,13 @@ def heal_shallow_history(repo_root: Path, branch: str, **run_kwargs) -> bool:
return _shallow_file_path(repo_root) is not None and fetch_full_commit_graph(repo_root, branch, **run_kwargs)
+# A tags-only refresh is a ref listing plus a few small tag objects; when GitHub is slow it can
+# stall for minutes, and a miss only leaves the version label stale until the next update. Filling
+# shallow history really transfers the commit graph, so it keeps the long budget.
+_TAG_REFRESH_TIMEOUT_SECONDS = 30
+_HISTORY_FETCH_TIMEOUT_SECONDS = 900
+
+
def fetch_full_commit_graph(repo_root: Path, *extra_refspecs: str, **run_kwargs) -> bool:
"""Refresh release tags and fill shallow history before publishing identity.
@@ -684,7 +691,8 @@ def fetch_full_commit_graph(repo_root: Path, *extra_refspecs: str, **run_kwargs)
*([f"--filter={fetch_filter}"] if fetch_filter else []),
"--no-tags", "origin", "refs/tags/v*:refs/tags/v*", *extra_refspecs],
cwd=str(repo_root), check=True, capture_output=True, text=True,
- encoding="utf-8", errors="replace", timeout=900, **run_kwargs,
+ encoding="utf-8", errors="replace",
+ timeout=_HISTORY_FETCH_TIMEOUT_SECONDS if shallow else _TAG_REFRESH_TIMEOUT_SECONDS, **run_kwargs,
)
finally:
# git writes the partial-clone config before it fetches, so a failed fetch converts too.
diff --git a/tests/hermes_cli/test_tag_fetch_partial_clone.py b/tests/hermes_cli/test_tag_fetch_partial_clone.py
index c583b1711cd..e7ce7625289 100644
--- a/tests/hermes_cli/test_tag_fetch_partial_clone.py
+++ b/tests/hermes_cli/test_tag_fetch_partial_clone.py
@@ -86,3 +86,30 @@ def test_tag_fetch_preserves_a_non_default_partial_clone_filter(tmp_path):
assert _git(checkout, "config", "--get", "remote.origin.partialclonefilter") == "blob:none"
assert "v0.21.6" in _git(checkout, "tag", "--list")
+
+
+def test_a_tag_refresh_is_bounded_short_and_a_history_fill_keeps_the_long_budget(tmp_path, monkeypatch):
+ # A tags-only refresh on a full-history checkout is a ref listing; a slow remote must not hold
+ # the update for 15 minutes when a miss only leaves the version label stale. Filling a shallow
+ # checkout's history really transfers commits, so it keeps the long budget.
+ from hermes_cli import gitlock
+
+ server = _server_repo(tmp_path)
+ _git(server, "config", "uploadpack.allowFilter", "true")
+ full = _clone(tmp_path, server, "full", "--no-tags")
+ shallow = _clone(tmp_path, server, "shallow", "--depth", "1")
+ seen = {}
+ real = gitlock.run_git
+
+ def recording(git_cmd, args, **kwargs):
+ if args[:1] == ["fetch"]:
+ seen[kwargs["cwd"]] = kwargs["timeout"]
+ return real(git_cmd, args, **kwargs)
+
+ monkeypatch.setattr(gitlock, "run_git", recording)
+ assert fetch_full_commit_graph(full) is False
+ assert fetch_full_commit_graph(shallow) is True
+
+ assert seen[str(full)] == gitlock._TAG_REFRESH_TIMEOUT_SECONDS == 30
+ assert seen[str(shallow)] == gitlock._HISTORY_FETCH_TIMEOUT_SECONDS == 900
+ assert "v0.21.6" in _git(full, "tag", "--list")