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

Ruff incorrectly ignores Python files included by negated pattern in .gitignore #8753

Open
henribru opened this issue Nov 18, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@henribru
Copy link

Given the following .gitignore:

*
!/src/
!/src/**

and a file src/foo.py, ruff src/ outputs warning: No Python files found under the given path(s). Given that Git includes this file due to the negated pattern overriding the *, this seems like a bug.

This is with 0.1.6 and no Ruff configuration in pyproject.toml.

@charliermarsh
Copy link
Member

@BurntSushi -- We use the ignore crate for .gitignore behavior. Would you expect src/foo.py to be included based on the above? (It could definitely be an error on our side and not in the ignore crate, but wanted to check with you first.)

@charliermarsh charliermarsh added the question Asking for support or clarification label Nov 18, 2023
@henribru
Copy link
Author

Seems like this might be BurntSushi/ripgrep#1050

@BurntSushi
Copy link
Member

It might also be this: BurntSushi/ripgrep#1757 (A fix was merged recently but I believe it has not been released yet.)

But yes, this looks like a bug in the ignore crate to me.

@eli-schwartz
Copy link
Contributor

@BurntSushi -- We use the ignore crate for .gitignore behavior. Would you expect src/foo.py to be included based on the above? (It could definitely be an error on our side and not in the ignore crate, but wanted to check with you first.)

I would expect files that are checked into git with git add --force to be checked, but maybe that is just me? 🤔

@MichaReiser MichaReiser added bug Something isn't working question Asking for support or clarification and removed question Asking for support or clarification labels Nov 27, 2023
@BurntSushi
Copy link
Member

The ignore crate only reads .gitignore files. It doesn't actually read the git repository state to determine what's tracked and what isn't. One possible work-around to this is to ensure that .gitignore files are in sync with your repository state.

@charliermarsh charliermarsh removed the question Asking for support or clarification label Nov 29, 2023
@charliermarsh
Copy link
Member

@BurntSushi - Did that fix go out in the latest version of ignore?

@BurntSushi
Copy link
Member

Yeah if the issue here is BurntSushi/ripgrep#1757 then that's in the latest ignore release.

But BurntSushi/ripgrep#1050 remains unfixed.

@charliermarsh
Copy link
Member

I actually can't reproduce this on v0.1.6. @henribru - is that the exact pattern and directory structure you were using?

@henribru
Copy link
Author

I actually can't reproduce this on v0.1.6. @henribru - is that the exact pattern and directory structure you were using?

Yes. But I discovered something curious: It only seems to reproduce on Windows.

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

No branches or pull requests

5 participants