Browse Source

fix(cli): use `matched_path_or_any_parents` when checking if a file is ignored (#8903)

* fix: taurignore ignoreing folders not working for watch

* docs: add to changes

* fix: panic: path is expected to be under the root

* Update taurignore-ignoring-folders-not-working-for-watch.md

* Update taurignore-ignoring-folders-not-working-for-watch.md
anatawa12 1 year ago
parent
commit
b15948b11c

+ 6 - 0
.changes/taurignore-ignoring-folders-not-working-for-watch.md

@@ -0,0 +1,6 @@
+---
+'tauri-cli': patch:bug
+'@tauri-apps/cli': patch:bug
+---
+
+Fix `.taurignore` failing to ignore in some cases.

+ 5 - 1
tooling/cli/src/interface/rust.rs

@@ -263,7 +263,11 @@ struct IgnoreMatcher(Vec<Gitignore>);
 impl IgnoreMatcher {
   fn is_ignore(&self, path: &Path, is_dir: bool) -> bool {
     for gitignore in &self.0 {
-      if gitignore.matched(path, is_dir).is_ignore() {
+      if path.starts_with(gitignore.path())
+        && gitignore
+          .matched_path_or_any_parents(path, is_dir)
+          .is_ignore()
+      {
         return true;
       }
     }