From 0fd11b7b2a37df2c81adc4f76c29679779b3478b Mon Sep 17 00:00:00 2001 From: erseco Date: Sat, 26 Sep 2026 08:10:37 +0100 Subject: [PATCH] Keep make up working with a dirty editor clone or no network build-editor runs bun install, which rewrites the editor clone's bun.lock. The next fetch-editor-source then refused to check out the new ref ("local changes would be overwritten"), so make up failed on every run after the first build once upstream moved. Discard that lockfile change before checkout. build-editor-if-needed also aborted make up whenever the fetch failed, for example offline, even with a usable build in dist/static. It now warns and keeps the existing build in that case. --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 95fba68..0af950f 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,9 @@ EDITOR_OUTPUT_DIR := $(CURDIR)/dist/static EDITOR_REPO_DEFAULT := https://github.com/exelearning/exelearning.git EDITOR_REF_DEFAULT := main -# Fetch editor source code from remote repository (clone or update existing) +# Fetch editor source code from remote repository (clone or update existing). +# build-editor's `bun install` rewrites bun.lock; that change is discarded +# before checkout so the next fetch can move the clone. fetch-editor-source: @set -e; \ get_env() { \ @@ -45,6 +47,7 @@ fetch-editor-source: git -C $(EDITOR_SUBMODULE_PATH) remote add origin "$$REPO_URL"; \ fi; \ OLD_HEAD=$$(git -C $(EDITOR_SUBMODULE_PATH) rev-parse HEAD 2>/dev/null || echo "none"); \ + git -C $(EDITOR_SUBMODULE_PATH) checkout -q -- bun.lock 2>/dev/null || true; \ case "$$REF_TYPE" in \ tag) \ git -C $(EDITOR_SUBMODULE_PATH) fetch --depth 1 origin "refs/tags/$$REF:refs/tags/$$REF"; \ @@ -112,8 +115,15 @@ build-editor: check-bun fetch-editor-source @echo "============================================" # Build only if needed: skip when dist/static/ exists and source hasn't changed -build-editor-if-needed: fetch-editor-source - @BUILD_COMMIT=""; \ +build-editor-if-needed: + @if ! $(MAKE) --no-print-directory fetch-editor-source; then \ + if [ -f "$(EDITOR_OUTPUT_DIR)/index.html" ]; then \ + echo "Warning: could not update the editor source; keeping the existing build."; \ + exit 0; \ + fi; \ + exit 1; \ + fi; \ + BUILD_COMMIT=""; \ if [ -f "$(EDITOR_OUTPUT_DIR)/.build-commit" ]; then \ BUILD_COMMIT=$$(cat "$(EDITOR_OUTPUT_DIR)/.build-commit"); \ fi; \