Artifact cc1130129e3c320cb9c1c5a05f505e45ece23d6bb3e0228da8e7ffe97bd5612b:
- Executable file
scripts/mirror-export.sh
— part of check-in
[ef4efe16b3]
at
2026-07-18 22:13:56
on branch trunk
— Add scripts/mirror-export.sh: the reproducible export to the private mirror
The mirror is a derived view for running CI, never a source of truth — fossil is the repository, and every push is a replay of fossil history, which is why it pushes --mirror and nothing is ever committed git-side.
Why a script when 'fossil git export' already works: its configuration (mirror directory and autopush URL) is per-checkout state, machine-local and invisible to anyone else cloning this repo. The script documents the one supported way to run the export and fails with the exact 'fossil git export ... --autopush ...' fix line when a checkout has never been configured.
It also re-drives the push explicitly rather than relying on autopush. Autopush is best-effort: the first export of the CI commit hit a transient connection refusal to github.com, left the local mirror ahead of the remote, and 'fossil git status' still reported up-to-date — because that status describes the export, not the push. Re-driving makes the push's exit status the script's.
The mirror is PRIVATE and stays private; the script never touches visibility. (user: dmestas, size: 2659) [annotate] [blame] [check-ins using]
#!/bin/sh # Export the fossil repository to its git mirror and push it. # # The mirror exists so GitHub Actions can run the release battery; it is a # derived view, never a source of truth. Fossil is the repository. Nothing is # ever committed on the git side — a push is always a replay of fossil history, # which is why the push is `--mirror`. # # The mirror repo is PRIVATE and stays private. Publishing zit is a separate, # deliberate decision; do not change repository visibility from this script or # from any automation that calls it. # # `fossil git export` keeps its own per-checkout state (mirror directory and # autopush URL, set up once with `fossil git export <dir> --autopush <url>`). # That state is machine-local and therefore invisible to anyone cloning this # repository, which is the reason this script exists: it makes the export # reproducible and documents the one supported way to run it. # # Usage: scripts/mirror-export.sh # Exit: 0 on a completed export+push, non-zero otherwise. set -eu MIRROR_URL="https://github.com/danmestas/zit" # Run from the repository root regardless of where the caller invoked this. cd "$(dirname "$0")/.." if ! command -v fossil >/dev/null 2>&1; then echo "mirror-export: fossil is not on PATH" >&2 exit 1 fi # `fossil git export` with no arguments resumes the configured mirror. If it has # never been configured in this checkout, say so with the fix rather than # failing obscurely three lines deeper. if ! fossil git status >/dev/null 2>&1; then echo "mirror-export: no git mirror configured in this checkout." >&2 echo " fossil git export /path/to/zit-mirror --autopush ${MIRROR_URL}" >&2 exit 1 fi echo "mirror-export: exporting fossil history to the git mirror" fossil git export # Autopush is best-effort inside fossil: a transient network failure leaves the # local mirror ahead of the remote while `fossil git status` still reports # "up-to-date", because that status describes the export, not the push. So the # push is re-driven explicitly and its exit status is the script's. MIRROR_DIR=$(fossil git status | awk '/^Git mirror:/ { print $3 }') if [ -z "${MIRROR_DIR}" ] || [ ! -d "${MIRROR_DIR}" ]; then echo "mirror-export: could not resolve the mirror directory from 'fossil git status'" >&2 exit 1 fi echo "mirror-export: pushing ${MIRROR_DIR} -> ${MIRROR_URL}" cd "${MIRROR_DIR}" # The mirror carries no LFS objects; the lock-verify probe only adds a failure # mode on a repo that has never used LFS. git config "lfs.${MIRROR_URL}.git/info/lfs.locksverify" false 2>/dev/null || true git push --mirror "${MIRROR_URL}" echo "mirror-export: done"