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

Add support for glob pattern #58

Merged
merged 4 commits into from Apr 1, 2021
Merged

Conversation

ndtoan96
Copy link
Contributor

Workaround for #56. Instead of regex, I think glob pattern would be more suited because the ignore crate already supported it.

types_builder.select(t);
if t.contains("*") {
let new_type = format!("type{}", cnt);
types_builder.add(&new_type, t).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignore::types::TypesBuilder::add only returns error when the name is wrong, not the glob. We control the name in this case so it can't go wrong. Thus I used unwrap here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point - consider putting that as a comment so that the next person to read the code know about this :)

types_builder.negate(t);
if t.contains("*") {
let new_type = format!("type{}", cnt);
types_builder.add(&new_type, t).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignore::types::TypesBuilder::add only returns error when the name is wrong, not the glob. We control the name in this case so it can't go wrong. Thus I used unwrap here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

@dmerejkowsky
Copy link
Collaborator

Also, the code around build_walker is starting to get complicated, so I really think we need more tests to make sure we did not break anything there.

@dmerejkowsky
Copy link
Collaborator

dmerejkowsky commented Mar 31, 2021

Apart from that, this is a good PR and I agree it's a good way to fix #56 - thank you for your contribution :)

@dmerejkowsky
Copy link
Collaborator

Looking good, let's merge this.

@dmerejkowsky dmerejkowsky merged commit 80d523b into your-tools:master Apr 1, 2021
@ndtoan96 ndtoan96 deleted the glob branch April 1, 2021 13:37
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.

None yet

2 participants