Skip to content

gitignore and extensions #2

@avolgha

Description

@avolgha

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...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions