Skip to content

Commit 36f5f1c

Browse files
committed
Remove stale git lock files before updating the source checkout
A run killed mid-fetch (e.g. container stop) leaves shallow.lock or index.lock behind, causing the next run to fail with 'Another git process seems to be running'. Since ensure_source_repo is the sole, sequential git driver, any lock present at startup is stale and safe to remove.
1 parent b4d9ab7 commit 36f5f1c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • libs/hackbot-runtime/hackbot_runtime

libs/hackbot-runtime/hackbot_runtime/source.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ def ensure_source_repo(source_repo: Path, repo_url: str) -> None:
1717
the remote HEAD. Recovers from a partial checkout left by an earlier failed
1818
run (e.g. the clone succeeded but the checkout ran out of disk).
1919
"""
20-
if (source_repo / ".git").exists():
20+
git_dir = source_repo / ".git"
21+
if git_dir.exists():
22+
# An earlier run killed mid-fetch (e.g. the container was stopped)
23+
# leaves stale lock files behind. Since each run drives git
24+
# sequentially, any lock present at startup is stale and safe to
25+
# remove.
26+
for lock in (git_dir / "shallow.lock", git_dir / "index.lock"):
27+
if lock.exists():
28+
log.warning("removing stale git lock %s", lock)
29+
lock.unlink()
2130
status = subprocess.run(
2231
["git", "-C", str(source_repo), "status", "--porcelain"],
2332
check=True,

0 commit comments

Comments
 (0)