-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
feature/traverse: Add an option to rely purely on ignore files for traversing directories #339
base: master
Are you sure you want to change the base?
Conversation
while let Some(path) = all_files.pop_front() { | ||
let x = if let Ok(meta) = path.metadata() { | ||
if meta.is_file() { | ||
match path.file_name().and_then(|x| x.to_str()) { | ||
Some(file_name) if file_name == "Cargo.toml" => Extraction::Manifest(path), | ||
Some(file_name) if file_name.ends_with(".md") => Extraction::Markdown(path), | ||
Some(file_name) if file_name.ends_with(".rs") => Extraction::Source(path), | ||
_ => { | ||
// This branch is commonly entered when ran on a non-cargo | ||
// path. | ||
// Potentially become mdbook aware | ||
// <https://github.com/drahnr/cargo-spellcheck/issues/273> | ||
log::debug!( | ||
"Unknown file type encountered, skipping path: {}", | ||
path.display() | ||
); | ||
continue; | ||
} | ||
} | ||
} else { | ||
Extraction::Missing(path) | ||
} |
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 think this part should become a function, it's (almost?) identical to the one in the else
branch.
let mut all_files = VecDeque::<PathBuf>::with_capacity(32); | ||
|
||
while let Some(path) = flow.pop_front() { | ||
let files = ignore::WalkBuilder::new(path) |
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.
Can we define a closure that gives us an iterator back rather than duplicating the if
and else
branch logic. It's been a mess before you came, but now I can see what I've done a few years back 😰
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.
With some delay, I am not opposed to the changes, yet with the added complexity some more code unification and carve outs need to be done before I'll merge this.
Sorry for the long review delay.
What does this PR accomplish?
Changes proposed by this PR:
This pr adds an option flag to change the behaviour of the traversal module to collect all relevant files except those which match an entry in a .gitignore file. Our usecase for this is to be able to ignore certain temporary Markdown files which are pulled in when building our documentation.
📜 Checklist
./demo
sub directory