Skip to content
Closed
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
15 changes: 15 additions & 0 deletions hermes_cli/update_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,21 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):
)
depth_args = ["--depth", "1"] if is_shallow else []

# Remove stale .git/shallow.lock left by interrupted updates (#75133).
# A previous git fetch that was killed mid-flight (network timeout,
# app force-close, system sleep) leaves this lock file behind. The
# next fetch then fails with "Unable to create '.git/shallow.lock':
# File exists", which the GUI misinterprets as a concurrent process
# and traps the user in an unrecoverable update loop.
if is_shallow:
_shallow_lock = os.path.join(_m().PROJECT_ROOT, ".git", "shallow.lock")
if os.path.exists(_shallow_lock):
try:
os.remove(_shallow_lock)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This --check path returns before UpdateLock is acquired (hermes_cli/main.py:8991-9020), so existence alone cannot establish that this lock is stale. It can unlink a lock held by a concurrent fetch; use a shared ownership/liveness guard instead of deleting solely because the path exists.

logger.debug("Removed stale .git/shallow.lock")
except OSError as exc:
logger.debug("Could not remove .git/shallow.lock: %s", exc)

if branch == "main":
# Probe locally (~6 ms) whether an 'upstream' remote exists at all
# before spending a network fetch on it. Non-fork installs have no
Expand Down