#!/bin/bash # The live round: as LIVE_HANDLE (app password in LIVE_PASSWORD), create a repository, make three # commits through the module, check them with a knotless clone, then delete it with knotless. # LIVE_HANDLE=you.bsky.social LIVE_PASSWORD=... bash live.sh (after cargo wasm) set -euo pipefail cd "$(dirname "$0")" H="${LIVE_HANDLE:?LIVE_HANDLE}" : "${LIVE_PASSWORD:?LIVE_PASSWORD}" export ATLIBS_SERVER_STATE=$(mktemp -d) export KNOTLESS_CONFIG_DIR=$(mktemp -d) KNOTLESS_CACHE_DIR=$(mktemp -d) NAME="atlibs-knotless-live-$(date +%s)" AS=(--app-password "$H" --password-env LIVE_PASSWORD) run() { env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD -u ATP_USERNAME -u ATP_PASSWORD -u ATPROTO_PDS atlibs run modules/knotless "$@" "${AS[@]}"; } run create_repo "{\"name\":\"$NAME\",\"description\":\"atlibs-knotless live test; deleted after\"}" | jq -c '{result, error}' run commit "{\"name\":\"$NAME\",\"branch\":\"main\",\"message\":\"first\",\"author\":\"Alice \",\"changes\":[{\"path\":\"README.md\",\"content\":\"# live\\none\\ntwo\\nthree\\n\"},{\"path\":\"src/run.sh\",\"content\":\"#!/bin/sh\\necho hi\\n\",\"executable\":true},{\"path\":\"gone.txt\",\"content\":\"x\\n\"}]}" | jq -c '{result, error}' run commit "{\"name\":\"$NAME\",\"branch\":\"main\",\"message\":\"second: patch and delete\",\"changes\":[{\"path\":\"README.md\",\"patch\":\"--- a/README.md\\n+++ b/README.md\\n@@ -2,3 +2,3 @@\\n one\\n-two\\n+TWO\\n three\\n\"},{\"path\":\"gone.txt\",\"delete\":true}]}" | jq -c '{result, error}' # A commit past 192 KiB: its pack goes over blobs (uploadBlob), and the next one reads it back (getBlob). BIG=$(mktemp); head -c 600000 /dev/urandom | base64 | jq -Rs --arg n "$NAME" '{name:$n,branch:"main",message:"big",changes:[{path:"big.txt",content:.}]}' > "$BIG" ATLIBS_BUDGET='{"ioBytes":16777216}' run commit "@$BIG" | jq -c '{pack: .result.pack, sha: .result.sha, error}' ATLIBS_BUDGET='{"ioBytes":16777216}' run commit "{\"name\":\"$NAME\",\"branch\":\"main\",\"message\":\"after big\",\"changes\":[{\"path\":\"after.txt\",\"content\":\"a\\n\"}]}" | jq -c '{result, error}' rm -f "$BIG" run commit "{\"name\":\"$NAME\",\"branch\":\"topic\",\"message\":\"topic\",\"changes\":[{\"path\":\"topic.txt\",\"content\":\"t\\n\"}]}" | jq -c '{result, error}' CLONE=$(mktemp -d) env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD -u ATP_USERNAME -u ATP_PASSWORD -u ATPROTO_PDS git clone -q "knotless://$H/$NAME" "$CLONE/r" git -C "$CLONE/r" log --format='%h %an <%ae> %s' --all git -C "$CLONE/r" ls-tree -r -l HEAD cat "$CLONE/r/README.md" git -C "$CLONE/r" fsck --strict --no-dangling && echo FSCK_OK git -C "$CLONE/r" branch -a # Delete the repository again with knotless itself. env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD -u ATP_USERNAME -u ATP_PASSWORD -u ATPROTO_PDS KNOTLESS_PASSWORD="$LIVE_PASSWORD" knotless login "$H" 2>&1 | grep -v "is out" || true env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD -u ATP_USERNAME -u ATP_PASSWORD -u ATPROTO_PDS knotless repo delete "knotless://$H/$NAME" --yes 2>&1 | grep -v "is out" || true env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD knotless repo refs "knotless://$H/$NAME" 2>&1 | grep -v "is out" || true env -u ATPROTO_HANDLE -u ATPROTO_PASSWORD knotless logout "$H" 2>&1 | grep -v "is out" || true rm -rf "$ATLIBS_SERVER_STATE" "$KNOTLESS_CONFIG_DIR" "$KNOTLESS_CACHE_DIR" "$CLONE"