#!/bin/sh # Dev genome bootstrap (compose git-init). Runs to completion at every up. set -eu # agent waits for this marker; stale markers from previous boots are cleared rm -f /will-dev/.ready ORIGIN=/will-dev/origin/will.git WORK=/will-dev/work # 1. origin: mirror the committed state of the real workspace if [ ! -d "$ORIGIN/objects" ]; then git clone --bare --quiet /workspace "$ORIGIN" else git -C "$ORIGIN" fetch --prune --quiet /workspace '+refs/heads/*:refs/heads/*' fi # 2. dev workspace: clone once, persists across boots if [ ! -d "$WORK/.git" ]; then git clone --quiet "$ORIGIN" "$WORK" fi # 3. node_modules: one-time copy (293M) if [ ! -d "$WORK/node_modules" ]; then echo 'dev: copying node_modules (one-time)' cp -a /workspace/node_modules "$WORK/node_modules" fi # 4. overlay the dirty workspace state, committed as dev-sync. # Skipped when will left uncommitted work, so nothing is clobbered. if [ -z "$(git -C "$WORK" status --porcelain)" ]; then rsync -a --delete \ --exclude .git --exclude node_modules --exclude .dev \ --exclude dist --exclude web/dist --exclude docs/dist --exclude coverage \ /workspace/ "$WORK/" git -C "$WORK" add -A git -C "$WORK" -c user.name=dev-sync -c user.email=dev-sync@local \ commit -m 'dev-sync: overlay workspace state at boot' --quiet || true else echo 'dev: work tree dirty, skipping overlay sync' fi git -C "$WORK" log --oneline -2 touch /will-dev/.ready