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

Glob matching ignores ignore list #869

Open
alerque opened this issue Jun 28, 2024 · 3 comments · May be fixed by #918
Open

Glob matching ignores ignore list #869

alerque opened this issue Jun 28, 2024 · 3 comments · May be fixed by #918
Labels
bug Something isn't working

Comments

@alerque
Copy link
Contributor

alerque commented Jun 28, 2024

If I add a file test.lua to my .styluaignore, it will correctly get ignored in both of these usages:

$ stylua --respect-ignores test.sua
$ ls *.lua | xargs stylua --respect-ignores

Unfortunately it does not get ignored if matched in a glob pattern:

$ stylua --respect-ignores -g '*.lua' .

I would have expected that scenario to skip the file as well, but it does not. In my case this causes problems in several projects and I have to manually generate lists of files with other tooling and pass them as arguments instead of being able to use glob patterns.

@JohnnyMorganz
Copy link
Owner

I can't seem to repro this on latest main if I understood correctly:
image

@JohnnyMorganz
Copy link
Owner

JohnnyMorganz commented Jun 28, 2024

I, in fact, did not understand correctly. Can repro when not explicitly listing the filepath i.e. stylua --respect-ignores -g '*.lua' .

It seems like the ignore (walkerbuilder) crate might be making explicit globs take precedence over ignore files. That would be unfortunate

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Jun 28, 2024
@JohnnyMorganz
Copy link
Owner

Indeed that seems to be the case: https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html

First, glob overrides are checked. If a path matches a glob override, then matching stops. The path is then only skipped if the glob that matched the path is an ignore glob. (An override glob is a whitelist glob unless it starts with a !, in which case it is an ignore glob.)

We should probably not use the glob support in walkerbuilder and do our own matching instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants