Skip to content

[Draft] Respect gitignore file when file watching (fixes #231140) #246661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jasonwilliams
Copy link
Contributor

@jasonwilliams jasonwilliams commented Apr 15, 2025

This fixes #231140, this should reduce the amount of file watching happening on large repositories and less triggering of git status.

This will read the .gitignore file and fetch the values which can then be passed to the file watcher, however, it does seem like the filewatcher only accepts a single glob pattern, so there doesn't seem to be a way for me to watch the directory but exclude the paths from the .gitignore.

@lszomoru do you have any idea on how to fix this or if there is a workaround?
For now on vscode's repo the pattern that gets passed through to the watcher looks like this:

{**/*,!.DS_Store,!.cache,!npm-debug.log,!Thumbs.db,!node_modules/,!.build/,!.vscode/extensions/**/out/,!extensions/**/dist/,!/out*/,!/extensions/**/out/,!build/node_modules,!coverage/,!test_data/,!test-results/,!test-results.xml,!vscode.lsif,!vscode.db,!/.profile-oss,!/cli/target,!/cli/openssl,!product.overrides.json,!*.snap.actual,!.vscode-test}

My assumtion for this not working is the **/* at the beginning is matching, however if i take that out of the group match and have it at the start, then followed by the group match nothing matches. So it doesn't look like VS Code's built in glob allows for both checks here (or maybe im using it wrong)

The same doesn't seem to work on the glob playground with parenthesis due to / being used in the patterns:
https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F%21%28.DS_Store%7C.cache%7Cnpm-debug.log%7CThumbs.db%7Cnode_modules%2F%7C.build%2F%7C.vscode%2Fextensions%2F%2A%2A%2Fout%2F%7Cextensions%2F%2A%2A%2Fdist%2F%7C%2Fout%2A%2F%7C%2Fextensions%2F%2A%2A%2Fout%2F%7Cbuild%2Fnode_modules%7Ccoverage%2F%7Ctest_data%2F%7Ctest-results%2F%7Ctest-results.xml%7Cvscode.lsif%7Cvscode.db%7C%2F.profile-oss%7C%2Fcli%2Ftarget%7C%2Fcli%2Fopenssl%7Cproduct.overrides.json%7C%2A.snap.actual%7C.vscode-test%29&matches=false&tests=positive-match.jpg&tests=npm-debug.log&tests=Thumbs.d%C2%A0&tests=this-should-match.txt

Steps to reproduce

  • open the vscode repo with this built and running
  • change a file from the gitignore
  • the onChange handler will fire (it shouldn't)

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.

Git status is triggering far too often on a large repo (during build)
2 participants