#!/usr/bin/env bash # Fetch the pinned mongodb/specifications test suites. # # Pinned, not vendored: the suites are ~175 JSON files that upstream rewrites # wholesale, and a pinned commit gives the same reproducibility as vendoring # without putting someone else's test corpus in this repo's history. PLAN D2 # requires the pin; `specifications/` is gitignored. # # Bump SPEC_COMMIT deliberately, in its own commit, and re-record the # scorecard in the same commit -- otherwise a scorecard delta cannot be told # apart from an upstream change. set -euo pipefail SPEC_COMMIT="615e0f9ca5f554614636c098225fbbf1be55565d" SPEC_REPO="https://github.com/mongodb/specifications.git" cd "$(dirname "$0")" DEST="specifications" if [ -d "$DEST/.git" ] && [ "$(git -C "$DEST" rev-parse HEAD 2>/dev/null || true)" = "$SPEC_COMMIT" ]; then echo "specs already at $SPEC_COMMIT" exit 0 fi rm -rf "$DEST" mkdir -p "$DEST" cd "$DEST" # Sparse + depth 1: the full history is ~100 MB and we need two directories. git init -q . git remote add origin "$SPEC_REPO" git config core.sparseCheckout true mkdir -p .git/info cat > .git/info/sparse-checkout <<'EOF' source/crud/tests/ source/unified-test-format/ EOF echo "fetching $SPEC_COMMIT ..." git fetch -q --depth 1 origin "$SPEC_COMMIT" git checkout -q FETCH_HEAD n=$(find source/crud/tests/unified -name '*.json' | wc -l | tr -d ' ') echo "specs at $SPEC_COMMIT ($n crud/unified json files)"