Fix sidecar: advance refs/heads/main after each commit

post-receive uses `git checkout -f <SHA>` which detaches HEAD in the bare
repo. Without this fix, sidecar commits advance the detached HEAD but not
refs/heads/main and are orphaned on the next push.

Also commits CLAUDE.md docs update and the retry-loop sync-vps.sh.
This commit is contained in:
brutsalvadi
2026-05-08 08:57:49 +02:00
parent e9dceafc27
commit a85a2eeb6d
3 changed files with 53 additions and 2 deletions
+10
View File
@@ -133,6 +133,16 @@ async def _git_commit(file_path: Path, handle: str, verb: str) -> None:
stderr=asyncio.subprocess.DEVNULL,
)
await commit.wait()
# post-receive uses `git checkout -f <SHA>` which detaches HEAD, so
# commits would advance the detached HEAD but not refs/heads/main and
# would be lost on the next push. Explicitly keep main up to date.
update_ref = await asyncio.create_subprocess_exec(
"git", "update-ref", "refs/heads/main", "HEAD",
cwd=str(_ROOT), env=env,
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL,
)
await update_ref.wait()
except Exception as e:
print(f"[git] commit failed for {rel}: {e}", flush=True)