Skip to content

fix(repo-mode): reuse canonical cached project slug (#2212) - #2218

Merged
16francej merged 1 commit into
garrytan:mainfrom
time-attack:plan-daily-gstack-pr
Jul 14, 2026
Merged

fix(repo-mode): reuse canonical cached project slug (#2212)#2218
16francej merged 1 commit into
garrytan:mainfrom
time-attack:plan-daily-gstack-pr

Conversation

@time-attack

@time-attack time-attack commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

gstack caches a project’s slug from the first time it’s seen (often the local folder name). If you add a GitHub origin later, gstack-repo-mode used to ignore that cache and invent a new slug from the remote URL. That wrote state into a second “twin” project folder, so history could look split or lost and you’d get duplicate untracked project dirs.

This fix makes gstack-repo-mode reuse the canonical cached slug from gstack-slug. Repos with no remote still return REPO_MODE=unknown. It runs from the git root so the PWD-keyed cache matches.

Fixes #2212

Tests

We built local Git workspaces that mimic real public repos people use with gstack, reproduced the twin-slug bug in each, then verified the fix:

  1. facebook/react — local folder react-local-history, cache slug first, then add https://github.com/facebook/react.git as origin. Before: wrote under facebook-react. After: keeps react-local-history and no twin dir.
  2. vercel/next.js — same flow with next-local-historyhttps://github.com/vercel/next.js.git.
  3. kubernetes/kubernetes — same flow with kubernetes-local-historyhttps://github.com/kubernetes/kubernetes.git.

Additional coverage:

  • No-origin repo still returns REPO_MODE=unknown and creates no project dir
  • Running from a subdirectory still writes under the git-root cached slug
  • Unusual origin URLs (spaces/parens) stay sanitized before mkdir

All 6 cases in test/gstack-repo-mode.test.ts pass via bun test test/gstack-repo-mode.test.ts.

gstack-repo-mode was re-deriving slugs from origin and writing twin project dirs; consume gstack-slug's cached sanitized slug instead.
@trunk-io

trunk-io Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@time-attack
time-attack force-pushed the plan-daily-gstack-pr branch 2 times, most recently from 009703a to 8aab6df Compare July 10, 2026 14:51
@time-attack

Copy link
Copy Markdown
Contributor Author

@16francej

@16francej
16francej merged commit e284c8e into garrytan:main Jul 14, 2026
@marcusLewi

marcusLewi commented Jul 17, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gstack-repo-mode bypasses gstack-slug's cache (state written under a divergent slug) and skips slug sanitization before mkdir

3 participants