Add config.lock retry with jitter to both worktree-add sites
Some checks are pending
CI / lint-and-test (push) Waiting to run

Parallel domain merges race on the bare repo's config file. The single
retry only covered one of two worktree-add call sites and used fixed
delay. Now both sites retry up to 3 times with increasing jitter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
m3taversal 2026-04-15 17:13:32 +01:00
parent 1755580b95
commit 0d3fe95522

View file

@ -318,8 +318,10 @@ async def _cherry_pick_onto_main(branch: str) -> tuple[bool, str]:
# Delete stale local branch if it exists from a previous failed attempt
await _git("branch", "-D", clean_branch)
rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main")
if rc != 0 and "could not lock config" in out:
await asyncio.sleep(random.uniform(0.5, 2.0))
for _retry in range(3):
if rc == 0 or "could not lock config" not in out:
break
await asyncio.sleep(random.uniform(0.5, 2.0 * (_retry + 1)))
await _git("branch", "-D", clean_branch)
rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main")
if rc != 0:
@ -577,6 +579,12 @@ async def _merge_reweave_pr(branch: str) -> tuple[bool, str]:
await _git("worktree", "remove", "--force", worktree_path)
await _git("branch", "-D", clean_branch)
rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main")
for _retry in range(3):
if rc == 0 or "could not lock config" not in out:
break
await asyncio.sleep(random.uniform(0.5, 2.0 * (_retry + 1)))
await _git("branch", "-D", clean_branch)
rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main")
if rc != 0:
return False, f"worktree add failed: {out}"