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

gitignore and extensions #2

Open
avolgha opened this issue Apr 11, 2023 · 1 comment
Open

gitignore and extensions #2

avolgha opened this issue Apr 11, 2023 · 1 comment

Comments

@avolgha
Copy link

avolgha commented Apr 11, 2023

Hey, I like your project and tried to use it today.
After building the source, I run it in my project just to find out that there are a few problems in the source code that I want to address.

First, you require the user to have a .gitignore file in his project. If the user does not have it, the program will fail at

let gitignore = fs::read_to_string(".gitignore")?;

To solve this error, I personally changed it to this:

let gitignore = fs::read_to_string(".gitignore");
let gitignore = if gitignore.is_ok() {
   gitignore
   .unwrap()
   .lines()
   .map(|line| line.trim())
   .filter(|line| !line.starts_with('#'))
   .map(|line| line.to_string())
   .collect::<Vec<String>>()
} else {
   vec![]
};

That works fine for me because now, having a gitignore is optional.

Second, you require the user to add extensions to all files. Files with no extensions will let the program fail aswell here:

if !supported_filetypes.contains(&entry.path().extension().unwrap().to_str().unwrap()) {
//                                                         ^^ here will it fail
    continue;
}

I solved that issue by using a let Some:

if let Some(extension) = &entry.path().extension() {
    if !supported_filetypes.contains(&extension.to_str().unwrap()) {
        continue;
    }
}

That were two things I wanted to address.
Nontheless, it is a great project and I hope somebody will find this usefull
~ Marius, 2023

maybe someone wants to create a pull request for that...?

@avolgha
Copy link
Author

avolgha commented Apr 11, 2023

And just to clarify, I'm not a rust dev so my code might not be that good

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

No branches or pull requests

1 participant