diff --git a/taskiq/cli/watcher.py b/taskiq/cli/watcher.py index e0ac0e2..a16264d 100644 --- a/taskiq/cli/watcher.py +++ b/taskiq/cli/watcher.py @@ -21,9 +21,17 @@ def __init__( ) -> None: self.callback = callback self.gitignore = None - gpath = path / ".gitignore" - if use_gitignore and gpath.exists(): - self.gitignore = parse_gitignore(gpath) + project_root = Path().resolve() + path = path.resolve() + + if use_gitignore: + while path != project_root.parent: + gpath = path / ".gitignore" + if gpath.exists(): + self.gitignore = parse_gitignore(gpath) + break + path = path.parent + self.callback_kwargs = callback_kwargs def dispatch(self, event: FileSystemEvent) -> None: