-
Notifications
You must be signed in to change notification settings - Fork 14
Respect .gitignore
#285
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
Respect .gitignore
#285
Conversation
fortitude/src/check.rs
Outdated
@@ -323,17 +328,21 @@ fn get_files<P: AsRef<Path>, S: AsRef<str>>( | |||
extensions: &[S], | |||
excludes: &FilePatternSet, | |||
exclude_mode: ExcludeMode, | |||
gitignore_mode: GitignoreMode, | |||
) -> Vec<PathBuf> { | |||
paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to build the walker at this level? Then we can avoid building a new walker for each individual directory. It might also make it easier to switch to the parallel walker in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do it this way initially but ran into a bunch of problems getting it to work properly. I can give it another go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7869a73 implements this. It makes the function a fair bit messier, as invalid paths need to be handled separately. WalkBuilder
will raise an error if it's given a path that doesn't exist, but we need them to persist (either that or we rewrite the whole way we're handling missing files, but as there are already outstanding bugs related to the reporting of missing files I'd rather keep things the way they are in this PR if we can).
I've made the requested changes. I think we may need to rethink how to handle invalid file paths and missing files, as the current method is to deliberately allow these to propagate out of fortitude/fortitude/src/check.rs Lines 986 to 1002 in e03b00a
Perhaps it would be better to instead return |
Could be an opportunity to add some |
There are a couple of bug reports I've been meaning to raise related to file searching, and I think a more general refactor of this part of the code will be needed, so the PRs to fix those would be a better place to add them. |
Fixes #231
I spent a while trying to get Ruff's implementation of this working, but it required pulling in a lot of additional infrastructure that I didn't fully understand, so this seemed the safer option.
The use of the
WalkBuilder
seems messy, but when I tried building and using it from a function chain I got all kinds of lifetime issues. Making itmut
and modifying it one line at a time seemed to do the trick.