From 514db8513541f81338e70fcc4e32bb63345175b9 Mon Sep 17 00:00:00 2001 From: Topito Date: Sat, 25 Apr 2026 14:01:16 +0700 Subject: [PATCH] fix(build): make .version writes resilient to missing git HEAD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The build script ends with three `git rev-parse HEAD > /dist/.version` calls. When gstack is built outside its own git checkout (e.g. installed into a fresh repo whose parent has no commits — Conductor's gstack template flow), git walks up the tree, finds an unborn HEAD, and aborts with code 128. The `&&`-chain then kills the whole build: error: script "build" exited with code 128 fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Wrap each call in a subshell with a fallback so the build always succeeds: (git rev-parse HEAD 2>/dev/null || echo unknown) > /dist/.version Behavior unchanged for normal checkouts — still writes the real SHA. Failure mode now writes 'unknown' instead of aborting. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89af11ee7d..2610ce23b8 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "make-pdf": "./make-pdf/dist/pdf" }, "scripts": { - "build": "bun run gen:skill-docs --host all; bun build --compile browse/src/cli.ts --outfile browse/dist/browse && bun build --compile browse/src/find-browse.ts --outfile browse/dist/find-browse && bun build --compile design/src/cli.ts --outfile design/dist/design && bun build --compile make-pdf/src/cli.ts --outfile make-pdf/dist/pdf && bun build --compile bin/gstack-global-discover.ts --outfile bin/gstack-global-discover && bash browse/scripts/build-node-server.sh && git rev-parse HEAD > browse/dist/.version && git rev-parse HEAD > design/dist/.version && git rev-parse HEAD > make-pdf/dist/.version && chmod +x browse/dist/browse browse/dist/find-browse design/dist/design make-pdf/dist/pdf bin/gstack-global-discover && (rm -f .*.bun-build || true)", + "build": "bun run gen:skill-docs --host all; bun build --compile browse/src/cli.ts --outfile browse/dist/browse && bun build --compile browse/src/find-browse.ts --outfile browse/dist/find-browse && bun build --compile design/src/cli.ts --outfile design/dist/design && bun build --compile make-pdf/src/cli.ts --outfile make-pdf/dist/pdf && bun build --compile bin/gstack-global-discover.ts --outfile bin/gstack-global-discover && bash browse/scripts/build-node-server.sh && (git rev-parse HEAD 2>/dev/null || echo unknown) > browse/dist/.version && (git rev-parse HEAD 2>/dev/null || echo unknown) > design/dist/.version && (git rev-parse HEAD 2>/dev/null || echo unknown) > make-pdf/dist/.version && chmod +x browse/dist/browse browse/dist/find-browse design/dist/design make-pdf/dist/pdf bin/gstack-global-discover && (rm -f .*.bun-build || true)", "dev:make-pdf": "bun run make-pdf/src/cli.ts", "dev:design": "bun run design/src/cli.ts", "gen:skill-docs": "bun run scripts/gen-skill-docs.ts",