Skip to content

Commit 04f2864

Browse files
committed
fix: Guard netlify-fetch against a failing branch listing
Review feedback (set -e at the top / pipefail): make runs every recipe line in its own shell, so a leading set -e would only govern itself, and the shell is sh, which has no pipefail - but the spirit of the comment found a real gap: a failing ls-remote inside the command substitution would have silently emptied the loop. The list is now captured and checked explicitly, and set -eu replaces set -e.
1 parent 5dc9fe0 commit 04f2864

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ netlify-fetch:
7070
# race the ref updates and silently leave a stale local branch behind,
7171
# which only surfaces much later as a missing-object error from antora.
7272
# 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 \
73+
set -eu; \
74+
branches="$$(git ls-remote --heads origin | sed 's|.*refs/heads/||' | grep -E 'release[/-]')"; \
75+
[ -n "$$branches" ] || { echo "netlify-fetch: no release branches from ls-remote - refusing to continue"; exit 1; }; \
76+
for branch in $$branches; do \
7477
git -c gc.auto=0 fetch origin "+refs/heads/$$branch:refs/heads/$$branch"; \
7578
git -c gc.auto=0 checkout -q "$$branch" -- . ; \
7679
done

0 commit comments

Comments
 (0)