From cf580f6b0c0952790c1c81328584f9f9a40477ec Mon Sep 17 00:00:00 2001 From: HansonHe-UW Date: Tue, 26 May 2026 19:23:26 -0400 Subject: [PATCH] Handle missing origin/data when generating fixtures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In shallow clones (e.g. `gh repo clone -- --depth 1`), or when cloning the public mirror (which does not include the `data` branch), running `./scripts/generate-fixtures.sh` without `FETCH_FIXTURES_FROM` fails with a cryptic `fatal: invalid reference: origin/data` from `git worktree`. Before invoking `git worktree add`, check whether `origin/data` is present locally and try to fetch it on demand. If the ref still cannot be obtained — which is the case for the public mirror — exit with an actionable error pointing the contributor at `FETCH_FIXTURES_FROM`. Fixes #49. --- scripts/generate-fixtures.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/generate-fixtures.sh b/scripts/generate-fixtures.sh index 94bc5ea..4e993b2 100755 --- a/scripts/generate-fixtures.sh +++ b/scripts/generate-fixtures.sh @@ -66,6 +66,30 @@ if [ -n "$__fetch_from" ]; then wget --no-verbose -O "$PROJECT_DIR/build/fixtures/user-profiles.json" "$__fetch_from/user-profiles.json" else echo "Generating fixtures..." + + # In shallow clones (e.g. `gh repo clone -- --depth 1`), or when cloning + # the public mirror — which does not contain the `data` branch — the + # `origin/data` ref may be missing locally. Try to fetch it on demand, + # and fall back to an actionable error if it is unavailable. + if ! git rev-parse --verify --quiet refs/remotes/origin/data >/dev/null; then + echo "origin/data not found locally; fetching..." + if ! git fetch --depth=1 origin data:refs/remotes/origin/data; then + cat >&2 <