Skip to content

Automatically ignore files specified in .gitignore#1234

Merged
charliermarsh merged 2 commits intomainfrom
charlie/ignore
Dec 14, 2022
Merged

Automatically ignore files specified in .gitignore#1234
charliermarsh merged 2 commits intomainfrom
charlie/ignore

Conversation

@charliermarsh
Copy link
Member

This is somewhat inefficient as I have to do two filesystem passes right now -- need to find a way to fix that...

Resolves #174.
Resolves #777.

let files: Vec<Result<DirEntry, walkdir::Error>> = WalkDir::new(path)
let files: Vec<Result<DirEntry, ignore::Error>> = Walk::new(path)
.into_iter()
.filter_entry(|entry| {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to use WalkBuilder, which should be pretty much a drop-in replacement for WalkDir (and let's me use the same filter_entry), but it's requiring that the lifetime of any variable in the closure if 'static? So I can't iteratively build up the shared resolver like I am now.

Copy link
Member Author

@charliermarsh charliermarsh Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code could be slow if you had a very large directory that wasn't marked as .gitignore but was excluded by Ruff. E.g., if you had a monorepo with a bunch of directories that contained JS files, we'd spend time traversing all of those.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing skip_gitignore for isort configuration Consider auto-excluding files matched by gitignore files

1 participant