1# Releases are refs, so a backup holds them with nothing more, and a2# restore links a public repo's downloads again, the same bytes with the3# same mtimes (so the mirror uploads nothing), and a private repo's into4# the private root, for its readers, never www.5. "$(dirname "$0")/../lib.sh"6user dami7repo dami/open8repo --private dami/secret9mkdir "$T/f"10printf 'tool\000\n' >"$T/f/tool"11export FORGE_USER=dami12for r in open secret; do13 clone dami "dami/$r" "$T/w/$r"14 at "$T/w/$r" commit "first"15 at "$T/w/$r" git tag v116 ok push_as dami "$T/w/$r" origin main17 ok at "$T/w/$r" "$FORGE" release publish v1 "$T/f/tool"18done19unset FORGE_USER20dl=releases/download/v121mtime() { node -p 'Math.floor(require("fs").statSync(process.argv[1]).mtimeMs)' "$1"; }22was=$(mtime "$FORGE_WWW/dami/open/$dl/tool")2324ok forge backup --dry-run25st=$FORGE_ROOT/.forge/backup/stage26missing "$st/.forge/store"27r=$T/restored28ok restore_into "$r" --from "$st"29ok cmp "$T/f/tool" "$r/.forge/www/dami/open/$dl/tool"30ok cmp "$FORGE_WWW/dami/open/$dl/SHA256SUMS.sig" "$r/.forge/www/dami/open/$dl/SHA256SUMS.sig"31exists "$r/.forge/www/dami/open/releases/download/latest/tool"32exists "$r/.forge/www/dami/open/releases/index.html"33eq "$(mtime "$r/.forge/www/dami/open/$dl/tool")" "$was"34missing "$r/.forge/www/dami/secret"35ok cmp "$T/f/tool" "$r/.forge/private/www/dami/secret/$dl/tool"36exists "$r/.forge/private/www/dami/secret/releases/download/latest/tool"37eq "$(git --git-dir="$r/dami/secret.git" rev-parse refs/releases/v1)" "$(git --git-dir="$FORGE_ROOT/dami/secret.git" rev-parse refs/releases/v1)"