#!/usr/bin/env bash # SPDX-License-Identifier: AGPL-3.0-only set -euo pipefail root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) allow=$root/scripts/public-snapshot.allow LC_ALL=C sort -c "$allow" [[ $(LC_ALL=C sort "$allow" | uniq -d | wc -l) -eq 0 ]] mapfile -t files <"$allow" [[ ${#files[@]} -gt 0 ]] for file in "${files[@]}"; do [[ -n $file && $file != /* && $file != *..* && $file != .gitea/* && $file != .github/* ]] git -C "$root" cat-file -e "HEAD:$file" done work=$(mktemp -d) trap 'rm -rf -- "$work"' EXIT mkdir -m 0700 "$work/tree" git -C "$root" archive HEAD -- "${files[@]}" | tar -xf - -C "$work/tree" test ! -e "$work/tree/.git" test ! -e "$work/tree/.gitea" test ! -e "$work/tree/.github" private_pattern='/home/[[:alnum:]_.-]+/|BEGIN (RSA|OPENSSH|EC) PRIVATE KEY|gitea[-_]api[[:alnum:]_.-]*token' if (cd "$work/tree" && rg -n --hidden --glob '!scripts/export-public.sh' --glob '!scripts/check-public-tree.sh' "$private_pattern" .); then echo "private material found in public tree" >&2 exit 1 fi (cd "$work/tree" && ./scripts/check-licenses.sh) (cd "$work/tree" && GOWORK=off go test -count=1 ./...) (cd "$work/tree" && GOWORK=off go vet ./...) (cd "$work/tree" && GOWORK=off CGO_ENABLED=0 go build -buildvcs=false -mod=readonly -trimpath -o "$work/tend" ./cmd/tend) echo "public tree compiles independently"