Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

browse: ensureStateDir appends .gstack/ to .gitignore when a file under .gstack/ is tracked

Open Beginner friendly
#3,467 0 comments 0 reactions 0 assignees View on GitHub

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from garrytan/gstack

All issues in garrytan/gstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.