Open jfly opened 3 months ago
Seems reasonable... Might be hard to know when we should raise this exactly. E.g., is it only when it's provided on the command-line? What if it comes from a configuration file? (I think true
is also the default so need to differentiate between "provided" and "not provided".)
A warning could also be reasonable here.
I think there's some more complication because respect_gitignore
should rather be named respect_ignore
because it doesn't just toggle .gitignore
, it also toggles whether ruff respects .ignore
, git ignore in parent directories, git global, git exclude, and ignores hidden files.
To me it's also unclear when such a warning would be shown? Is it when ruff doesn't find any gitignore or only if there is no gitignore in the root directory? Limiting it to the former seems overly restrictive but the latter has the downside that ruff always has to walk the tree eagerly even when only linting a subset of the files.
keywords: respect-gitignore
In https://github.com/astral-sh/ruff/issues/5930, ruff tried to start respecting
.gitignore
files even when outside of a git repo. Unfortunately, we had to revert that.I'm not asking to reconsider that revert: I understand that it had to happen. However, I do think it would be useful if
--respect-gitignore
would error out when run outside of a git repo. I personally find the current behavior quite confusing, and lost some time today trying to understand why ruff was disrespecting my.gitignore
even though I asked it to respect it!I'd be happy to send in a PR implementing this if you're open to it.
Thanks for the great tool!