fix(build): make .version writes resilient to missing git HEAD#1207
Open
topitopongsala wants to merge 1 commit intogarrytan:mainfrom
Open
fix(build): make .version writes resilient to missing git HEAD#1207topitopongsala wants to merge 1 commit intogarrytan:mainfrom
topitopongsala wants to merge 1 commit intogarrytan:mainfrom
Conversation
The build script ends with three `git rev-parse HEAD > <dir>/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) > <dir>/dist/.version
Behavior unchanged for normal checkouts — still writes the real SHA.
Failure mode now writes 'unknown' instead of aborting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wrap each
git rev-parse HEAD > <dir>/dist/.versioncall in thebuildscript with a subshell + fallback:(applied identically for
design/dist/.versionandmake-pdf/dist/.version).Why
When gstack is built outside its own git checkout — most notably Conductor's "Quick start → gstack template" flow, which clones gstack into a brand-new repo's
.claude/skills/gstack/(no.gitof its own; parent repo has no commits, soHEADis unborn) —git rev-parse HEADexits 128 with:The
&&chain then kills the entire build:…which surfaces in Conductor as
Failed to create repo: error: script "build" exited with code 128and the gstack template wipes the workspace before the user can inspect anything.The
.versionfiles are pure metadata — they shouldn't be load-bearing on the build's success.After this fix
.git-less install / unborn parent HEAD: writesunknownand the build proceeds. ✅Verification
Out of scope
This PR doesn't touch the broader question of whether the install flow should hand gstack a real
.gitor copy.versionfiles in some other way — it's the smallest possible patch to stop killing the build. Happy to follow up if maintainers prefer a different approach.