Skip to content

Commit 60da93f

Browse files
committed
Fix .gitgnore search in FileWatcher
1 parent 3770e73 commit 60da93f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

taskiq/cli/watcher.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ def __init__(
2121
) -> None:
2222
self.callback = callback
2323
self.gitignore = None
24-
gpath = path / ".gitignore"
25-
if use_gitignore and gpath.exists():
26-
self.gitignore = parse_gitignore(gpath)
24+
project_root = Path().resolve()
25+
path = path.resolve()
26+
27+
if use_gitignore:
28+
while path != project_root.parent:
29+
gpath = path / ".gitignore"
30+
if gpath.exists():
31+
self.gitignore = parse_gitignore(gpath)
32+
break
33+
path = path.parent
34+
2735
self.callback_kwargs = callback_kwargs
2836

2937
def dispatch(self, event: FileSystemEvent) -> None:

0 commit comments

Comments
 (0)