browse: ensureStateDir appends .gstack/ to .gitignore when a file under .gstack/ is tracked
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- git, typescript
- Domain
- devtools
Research direction
Start with ensureStateDir() and isIgnoredByGit() in browse/src/config.ts, then reproduce the case using the .gitignore entries and commands in the issue. Check that running a $B command no longer appends .gstack/ when a tracked file under that directory is intentionally included. Confirm that the re-include rule for .gstack/pregate.json remains effective.
Written by the indexing model from the issue text.
Description
What happens
ensureStateDir() in browse/src/config.ts appends .gstack/ to the project's .gitignore when the project already ignores the folder's contents with .gstack/* and tracks one file inside it (for example a shared .gstack/pregate.json, added with git add -f).
The check it relies on, git check-ignore -q -- .gstack/, exits 1 once any file under .gstack/ is tracked, so isIgnoredByGit returns false. The text check then looks for a literal .gstack/ line, doesn't find .gstack/*, and appends. Every $B start leaves a modified tracked .gitignore, and the appended .gstack/ line also cancels a !.gstack/pregate.json re-include for anyone who hasn't added the file yet.
This is a variant of #2385, which fixed the global-excludes case.
Repro
Git 2.54 (Windows 11, Git Bash), gstack 1.91.239.0:
git init -q repro && cd repro
printf '.gstack/*\n!.gstack/pregate.json\n' > .gitignore
mkdir .gstack && echo '{}' > .gstack/pregate.json
git add .gitignore && git add -f .gstack/pregate.json
git check-ignore -q -- .gstack/; echo $? # 1 (what browse checks today)
git check-ignore -q -- .gstack/browse.json; echo $? # 0
git check-ignore -q --no-index -- .gstack/; echo $? # 0
Then run any $B command in that repo: .gitignore gains a .gstack/ line.
Suggested fix
Ask git about a path inside the state folder, which is what actually needs to stay out of commits:
// browse/src/config.ts, ensureStateDir()
if (isIgnoredByGit(config.projectDir, '.gstack/') ||
isIgnoredByGit(config.projectDir, '.gstack/browse.json')) return;
(git check-ignore --no-index -- .gstack/ also answers 0 here.) The .gstack/.gitignore containing * that the function already writes keeps the contents out of commits either way, so skipping the append is safe.
- Dominant language
- TypeScript
- Stars
- 137k
- Forks
- 20.3k
- Avg merge
- 8h 56m
- Merged PRs (30d)
- 239
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from garrytan/gstack
-
ship-queue
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 70/100
garrytan/gstack#3091 · 1 comment ·
Maintainers usually reply within 1 day
-
parked
Difficulty 1/5 Under an hour Newbie friendliness 85/100
garrytan/gstack#2943 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
garrytan/gstack#3512 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Add: ON Phim Viet SDOpencheck:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:agents area:cost bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
anthropics/claude-code#105375 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
galaxyproject/loom#616 ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 comment ·
Maintainers usually reply within 1 day