-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Include nested gitignores with pants_ignore
to ignore for file watching
#18654
Conversation
6a03be5
to
61ad6fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
Note that the downside of using walkdir
is that our filesystem watching will not be invalidated when .gitignore
files are changed. For the root .gitignore
we work around that by adding .gitignore
as an invalidation glob which restarts pantsd
on change, but I don't know if we should do that in this case, because it would mean walking the entire repository on startup.
I think that I would be ok with noting that as a caveat in the help
for the option, but it would be worth opening a new issue about.
This PR already now walks the entire repository on startup to create the ignores. This would be by changing
I'm okay with a warning, but strongly prefer fixing it if feasible. |
61ad6fe
to
0079d69
Compare
pants_ignore
to ignore for file watchingpants_ignore
to ignore for file watching
Yea. And my concern would be that that is the first "entire repo" glob in there (rather than being anchored somewhere at the root), meaning that the glob that Pants needs to poll to decide whether to restart is invalidated by any change anywhere in the repo. I'm not sure how much of a concern that is though. #10705 will make it cheaper to clean nodes which haven't actually been impacted by a change. |
Ah, that's the difference. This current implementation only walks the entire repo once, whereas if we change invalidation globs we'd now be polling the whole repo. But question, is that any different than the status quo? For example, this is our current config: Lines 48 to 54 in c49e56a
Unless the pattern is prefixed by |
I think that because of how we implement our globs, those existing globs aren't equivalent: we don't have recursive semantics by default in our globs (without a leading |
@stuhood I don't know about that. These globs look like they follow the gitignore rules. Are you saying they will only match files in the repo root? Lines 48 to 50 in 2486ba8
pants/src/python/pants/option/global_options.py Lines 1946 to 1949 in 2486ba8
|
Confusingly, exclude patterns do match The difference in this case is that our include rules are not implicitly recursive. To make them recursive, you need the |
What's the status on this? |
Closes #5682.
We need a single
Gitignore
for the whole Pants run to set up here:pants/src/rust/engine/src/context.rs
Lines 585 to 595 in 4ce704b
We can do that by merging gitignores from subdirectories as if they were in the top-level gitignore. We only need to relativize all their globs and ensure they take higher precedence.