Skip to content
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

Find out which paths to watch #78

Closed
wmertens opened this issue Jan 17, 2022 · 4 comments
Closed

Find out which paths to watch #78

wmertens opened this issue Jan 17, 2022 · 4 comments

Comments

@wmertens
Copy link

to set up recursive watchers of paths, it would be a good optimization to skip watching paths if there are no unignored files under them.

Ideally, filter() would return a skip parameter like node-watch uses: https://github.com/yuanchuan/node-watch/blob/master/README.md#:~:text=skip%20ignored%20directories%20by%20returning%20the%20skip%20flag

Then we'd also need a list of directories that are unignored under ignored directories, so that they can be watched separately.

so e.g.

/*/
!/foo/
!/bar/hello/
!/uhm/hello

would return skip on all paths under root except for "foo" and "uhm", and it would have a list of also-to-watch ['/bar/hello'].

All this is assuming that directories are correctly marked with a trailing /; if not they would be considered as files and this would be a safe fallback to recursing.

@kaelzhang
Copy link
Owner

I don't exactly understand your problem

@wmertens
Copy link
Author

I would like to know, for a given path, if all possible subpaths are ignored, or not.

In other words, is there a matching regex that ignores the path and no unignore regexes that match subpaths?

This knowledge is useful for monitoring a git workdir on Linux for changes. You can't get filesystem events for subtrees so you must recurse, and if a subtree is fully ignored you don't need to recurse into it.

@kaelzhang
Copy link
Owner

kaelzhang commented Jan 28, 2022

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".

From gitignore spec

And node-ignore is an JavaScript implementation according to the gitignore spec

I suggest to get better understanding about the usage of .gitignore file

@kaelzhang
Copy link
Owner

/*/
!/bar/hello/

Will not work expectedly, coz /bar is already ignored

Change it to

/*
!/bar
/bar/*
!/bar/hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants