#!/usr/bin/env bash # SPDX-License-Identifier: AGPL-3.0-only set -euo pipefail root=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) [[ -z $(git -C "$root" status --porcelain=v1 --untracked-files=all) ]] || { echo "snapshot test requires a clean committed worktree" >&2 exit 1 } parent=$(mktemp -d) trap 'rm -rf -- "$parent"' EXIT destination=$parent/public go run "$root/scripts/export-public-snapshot.go" --source "$root" --destination "$destination" test -f "$destination/PUBLIC-SNAPSHOT.json" test -f "$destination/PUBLIC-SNAPSHOT.sha256" test ! -e "$destination/.git" (cd "$destination" && sha256sum -c PUBLIC-SNAPSHOT.sha256) if go run "$root/scripts/export-public-snapshot.go" --source "$root" --destination "$destination"; then echo "snapshot exporter altered an existing destination" >&2 exit 1 fi