diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py index c99d56a81e18b..148bdba7b4f04 100644 --- a/hermes_cli/update_cmd.py +++ b/hermes_cli/update_cmd.py @@ -3744,9 +3744,22 @@ def _cmd_update_impl(args, gateway_mode: bool): # against. branch = _m()._resolve_update_branch(args) + # Detect shallow repo — a plain `git fetch` would unshallow it, + # dragging in the entire history (the exact cost `--depth 1` avoided). + is_shallow = ( + subprocess.run( + git_cmd + ["rev-parse", "--is-shallow-repository"], + cwd=_m().PROJECT_ROOT, + capture_output=True, + text=True, encoding="utf-8", errors="replace", + ).stdout.strip() + == "true" + ) + depth_args = ["--depth", "1"] if is_shallow else [] + print("→ Fetching updates...") fetch_result = subprocess.run( - git_cmd + ["fetch", "origin", branch], + git_cmd + ["fetch"] + depth_args + ["origin", branch], cwd=_m().PROJECT_ROOT, capture_output=True, text=True, encoding="utf-8", errors="replace",