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

Replace glob_match with globset #250

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Replace glob_match with globset #250

merged 2 commits into from
Mar 6, 2024

Conversation

jacobotb
Copy link
Contributor

@jacobotb jacobotb commented Mar 6, 2024

What problem are you trying to solve?

The glob_match crate has a bug with a pattern like **/*test*.py , where a file like abc/test/def/test.py does not match.

Or even t/test.py does not match.

See devongovett/glob-match#9 for issue.

What is your solution?

The globset crate does not have that bug and is pretty fast too.

Alternatives considered

What the reviewer should know

globset has a separate compilation step, so I do it during configuration parsing.

The glob_match crate has a bug with a pattern like **/*test*.py ,
where a file like abc/test/def/test.py does not match.

Or even t/test.py does not match.
@jacobotb jacobotb requested a review from juli1 March 6, 2024 15:37
@jacobotb jacobotb marked this pull request as ready for review March 6, 2024 15:37
@juli1 juli1 requested a review from jasonforal March 6, 2024 16:24
Comment on lines +156 to +162
fn matches_pattern(pattern: &PathPattern, path: &str) -> bool {
pattern
.glob
.as_ref()
.map(|g| g.is_match(path))
.unwrap_or(false)
|| Path::new(path).starts_with(&pattern.prefix)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we implement this as part of the PathPattern struct?

impl PathPattern {
   fn match(path: &str) {
      ....
   }
}

This way, we made sure we tie/attach this function to each type? This occurred to me after reading the clarification about the `PathPattern`, it seems this function would be part of the "type".

@juli1
Copy link
Collaborator

juli1 commented Mar 6, 2024

Approved and agreed on a follow up to make the function as part of a type.

@jacobotb jacobotb merged commit 7c950ca into main Mar 6, 2024
28 checks passed
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.

2 participants