Repository navigation
fix(cli): keep watching folders matched by .taurignore, filter entries and events - #16398
Conversation
Package Changes Through 8048ddbThere are 9 changes which include @tauri-apps/api with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-codegen with patch, tauri-runtime with patch, tauri with patch, tauri-runtime-wry with patch, tauri-utils with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Legend-Master
left a comment
There was a problem hiding this comment.
Negative matches are a bit tricky to support actually, I don't think always ignoring /* as a special case makes sense here. I wonder if we should just always watch the folders but ignore the events instead? cc @FabianLars
|
Hey @Legend-Master, thanks for pointing that out. You are completely right about not handling /* as a special case, and your suggestion makes total sense. I pushed a new commit (9ed83d4) that removes that root exception entirely. Now the watcher always walks the watch folders instead of skipping them when the root matches: - for path in watch_folders {
- if !ignore_matcher.is_ignore(&path, true) {
- log::info!("Watching {} for changes...", display_path(&path));
- lookup(&path, |file_type, p| { /* watch p */ });
- }
+ for path in &watch_folders {
+ log::info!("Watching {} for changes...", display_path(path));
+ }
+ for (path, mode) in watch_targets(&watch_folders) {
+ log::debug!("Watching {} for changes...", display_path(&path));
+ let _ = watcher.watch(&path, mode);
}We use a small helper called watch_targets that relies on the existing lookup walker to pick up only the entries that are actually not ignored: fn watch_targets(watch_folders: &[PathBuf]) -> Vec<(PathBuf, RecursiveMode)> {
let mut targets = Vec::new();
for path in watch_folders {
lookup(path, |file_type, p| {
if p != *path {
let mode = if file_type.is_dir() {
RecursiveMode::Recursive
} else {
RecursiveMode::NonRecursive
};
targets.push((p, mode));
}
});
}
targets
}Change events are still filtered properly by the event loop. I also updated the tests to cover this properly, using the
Running I cleaned up the PR title and description to match the new approach. Let me know what you think! |
Closes tauri-apps#9163. Prevents `IgnoreMatcher` from treating `.taurignore`'s root directory as ignored when using `/*`, matching standard `.gitignore` behavior. Includes unit tests.
…s and events Walk every watch folder even when an ignore pattern such as `/*` matches the folder itself, and apply the ignore rules to its entries and to change events. This replaces the root special case in IgnoreMatcher::is_ignore.
429cb6c to
db4552f
Compare
There was a problem hiding this comment.
This looks correct to me, thanks!
cc @FabianLars I'm not the most familiar with how file watchers are done, so want to ask you for a review as well
from my past experiences with https://github.com/parcel-bundler/watcher used in vscode, they seemed to just watch the whole folder and then match ignore patterns before it reaches the application code, this change basically matches that
FabianLars
left a comment
There was a problem hiding this comment.
not tested but looks reasonable
Closes #9163.
The watcher always walks the watch folders instead of skipping them when the root matches an ignore pattern like
/*. A small helper,watch_targets, relies on the existinglookupwalker to pick up only the entries that are not ignored, and change events are still filtered by the event loop. Includes unit tests and an end-to-end check with the.taurignorefrom #9163.