fix(update): fail safely on Git index locks - #63041
Conversation
|
Review note: this currently treats lock age as ownership. A legitimate Git operation can hold The issue calls for confirming that no live Git process owns the repository. Could the guard establish that condition (with regression coverage), or otherwise fail early with a precise recovery hint rather than deleting based on mtime alone? |
5ff77c8 to
021ab3b
Compare
|
Agreed. I removed the mtime-based deletion entirely. The updated guard now preserves every |
|
Thanks for revising this to preserve every lock rather than infer ownership from mtime. Current main's updater has no No correctness issue was identified in the reviewed diff. GitHub currently reports the PR mergeable against main. Automated hermes-sweeper review. |
48ad330 to
51a8b22
Compare
51a8b22 to
93214ec
Compare
|
Rebased onto current |
What does this PR do?
Makes
hermes updatefail safely when Git'sindex.lockexists. The updater no longer treats lock age as proof of ownership and never deletes the lock automatically. It exits before backup or Git mutation, prints the exact lock path, and gives a platform-specific recovery command for use only after the user confirms no Git operation is running.The guard resolves both normal
.git/directories and linked-worktree.gitpointer files.Related Issue
Refs #3523. The narrower report #63038 was closed in favor of the existing updater issue.
Relationship to existing #3523 PRs
index.lockbefore updater mutation.This PR adds the missing default-checkout preflight. It follows the stronger fail-closed lesson from prior update work: preserve every lock, abort before backup/Git mutation, and provide exact recovery guidance rather than guessing ownership from mtime.
Type of Change
Changes Made
hermes_cli/update_cmd.py: resolve the real index-lock path for normal checkouts and linked worktrees; abort before backup/Git mutation without deleting the lock.hermes_cli/main.py: re-export the moved helpers through the existing compatibility surface.tests/hermes_cli/test_update_stale_index_lock.py: cover fresh and old locks, missing locks, linked worktrees, Windows recovery guidance, and the no-mutation call order.How to Test
python -m pytest -q tests/hermes_cli/test_update_orphan_backend_reap.py tests/hermes_cli/test_update_venv_health.py tests/hermes_cli/test_update_stale_index_lock.py— 27 passed.uv.exe tool run ruff check hermes_cli/main.py hermes_cli/update_cmd.py tests/hermes_cli/test_update_stale_index_lock.py tests/hermes_cli/test_update_venv_health.py tests/hermes_cli/test_update_orphan_backend_reap.py— passed.python scripts/check-windows-footguns.py --all— no Windows footguns in 964 files.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Not applicable; regression coverage exercises the CLI output and preserves the lock file.