v1.15.1.0 fix(gstack-slug): subdir guard + .gstack-slug override + --reset (#1125)#1224
Open
gregario wants to merge 2 commits intogarrytan:mainfrom
Open
v1.15.1.0 fix(gstack-slug): subdir guard + .gstack-slug override + --reset (#1125)#1224gregario wants to merge 2 commits intogarrytan:mainfrom
gregario wants to merge 2 commits intogarrytan:mainfrom
Conversation
Fixes garrytan#1125. `bin/gstack-slug` derives the project slug from `git remote get-url origin`, which walks up parent directories. A standalone project living inside an outer git repo silently inherited the outer's slug, contaminating `~/.gstack/projects/{slug}/` with cross-project artifacts. The cache had no invalidation path, so once wrong, it stayed wrong. Three changes: 1. Subdir guard. Compare `git rev-parse --show-toplevel` against `$PWD`. When they differ, skip the remote-URL inference and fall through to `.gstack-slug` or basename. Eliminates the silent cross-contamination. 2. Per-project override. A `.gstack-slug` file in `$PWD` (one line, sanitized to [a-zA-Z0-9._-]) wins over git inference. Cheap, explicit, survives gstack-upgrade. 3. `--reset` flag. Removes the cache entry for the current PWD so users can recover from a previously-poisoned slug without manual cleanup of `~/.gstack/slug-cache/`. Tests cover the regression (subdir does not inherit outer remote), both override paths (toplevel and subdir), input sanitization, --reset behavior, and cache stability across runs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Fixes #1125 —
gstack-sluginherits the outer repo's slug when\$PWDis a subdirectory of a different git repo, then locks the wrong slug into~/.gstack/slug-cache/with no recovery path.Before
~/.gstack/projects/me-workspace/now collects artifacts for an unrelated project. Manual cleanup of both~/.gstack/projects/and~/.gstack/slug-cache/was needed to recover.After
Three changes
git rev-parse --show-toplevelagainst\$PWD. If they differ, skip the remote-URL inference and fall through to.gstack-slugor basename. Eliminates the silent cross-contamination..gstack-slugper-project override. A one-line file in\$PWD(sanitized to[a-zA-Z0-9._-]) wins over git inference. Cheap, explicit, survivesgstack-upgrade.gstack-slug --reset. Removes the cache entry for the current PWD without manual cleanup of~/.gstack/slug-cache/.Mirrors the shape of @snowmaker's merged PR #897 (deterministic slugs across sessions): one
bin/script change, one regression test file, zero behavior change for the happy path.Test plan
bun test test/gstack-slug.test.ts— 10 cases pass.gstack-slugoverride at toplevel and in subdir;, spaces, multi-line)--resetclears the cache file; no-op when cache absentbun test(full free suite) — greenFiles
bin/gstack-slug— fixtest/gstack-slug.test.ts— new, 10 casesVERSION,CHANGELOG.md— release v1.15.1.0🤖 Generated with Claude Code