Skip to content

Commit 5dc9fe0

Browse files
committed
fix: Fetch complete release-branch trees in netlify-fetch
Production builds failed with antora unable to find object e9b0f5d on release-26.7. That object is the ui/NOTICE blob: release-26.7 is the first release branch cut after the UI was vendored into this repo, so ui/ is regular content there instead of a submodule gitlink - and the blob-materializing loop excluded ui/ from its pathspec checkouts, a rule written when every release branch still had the submodule. Antora reads the whole tree of a content branch with isomorphic-git, which cannot fetch missing objects on demand, and died on the first ui blob. Reproduced and verified against a fresh blobless clone: with the exclusion the exact production error appears, without it the build passes and no tip objects are missing. Dropping the exclusion is harmless for the old branches: a gitlink has no blobs to fetch. Additional hardening while in here: - branch list from git ls-remote instead of the cached remote-tracking refs (make expanded the old list before the fetch even ran, so a brand-new release branch was invisible to its first build) - no more silent failures: set -e and no -q on fetch abort the build at the failing command instead of surfacing later as a confusing antora error - gc.auto=0 inside the loop and git fetch --all --prune keep the long-lived netlify build cache tidy and race-free
1 parent 1f51229 commit 5dc9fe0

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Makefile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,25 @@ clean:
5454
rm -rf cache
5555

5656
# The netlify repo is checked out without any blobs. Antora needs local
57-
# release branches and their blobs in the object database, so this target
58-
# creates/updates the local branches and materializes their blobs via
59-
# pathspec checkouts - without ever switching HEAD (enabling branch previews!).
60-
# ui/ is excluded: release branches still reference it as a submodule and
61-
# its blobs are not needed (the UI bundle is built from the current checkout).
57+
# release branches and their complete tip trees in the object database (it
58+
# reads them with isomorphic-git, which cannot fetch missing objects on
59+
# demand), so this target creates/updates the local branches and
60+
# materializes their blobs via pathspec checkouts - without ever switching
61+
# HEAD (enabling branch previews!).
6262
netlify-fetch:
6363
# netlify messes with some files, restore everything to how it was:
6464
git reset --hard
6565
# fetch, because netlify does caching and we want to get the latest commits
66-
git fetch --all
67-
for remote in $(shell git branch -r | grep -E 'release[/-]'); do \
68-
branch="$${remote#origin/}"; \
69-
git fetch -q origin "+refs/heads/$$branch:refs/heads/$$branch"; \
70-
git checkout -q "$$branch" -- ':(exclude)ui' . ; \
66+
git fetch --all --prune
67+
# The branch list comes from the remote so it is current even on the first
68+
# build after a new release branch appears (the cached remote-tracking refs
69+
# lag behind). Auto-gc is disabled inside the loop: a background gc can
70+
# race the ref updates and silently leave a stale local branch behind,
71+
# which only surfaces much later as a missing-object error from antora.
72+
# Failures abort the build immediately instead.
73+
set -e; for branch in $$(git ls-remote --heads origin | sed 's|.*refs/heads/||' | grep -E 'release[/-]'); do \
74+
git -c gc.auto=0 fetch origin "+refs/heads/$$branch:refs/heads/$$branch"; \
75+
git -c gc.auto=0 checkout -q "$$branch" -- . ; \
7176
done
7277
# restore the working tree of the current commit and drop files that
7378
# only exist on other branches (ignored files like node_modules stay)

0 commit comments

Comments
 (0)