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

Implement new glob recipe #119

Merged
merged 1 commit into from
Aug 31, 2024
Merged

Implement new glob recipe #119

merged 1 commit into from
Aug 31, 2024

Conversation

kylewlacy
Copy link
Member

Closes #79

This PR implements the new glob recipe type, which takes a directory recipe and a list of patterns, and bakes to a new directory filtered down based on the list of patterns.

Even though Brioche already uses globset for glob matching, I ended up using Wax to match glob patterns for the glob recipe. This is because globset (and most other glob matching libraries) use std::path::Path somewhere in the pipeline, which might lead to different behavior depending on the host platform. On the other hand, Wax is meant to be portable across platforms, so it's a good fit for this use case

One limitation around Wax is that the paths to match against must be &strs, which mean they must be valid UTF-8. Brioche currently doesn't enforce that filenames are UTF-8, so paths in artifacts are converted using String::from_utf8_lossy, which means that wildcards will even work with invalid UTF-8 sequences in paths (this also means a glob pattern can use the Unicode replacement character (�) to match an invalid UTF-8 byte)

I also disallowed any glob patterns from containing !. As far as I can tell, Wax doesn't handle "negative patterns" natively, so I wanted to reserve ! in case we wanted to support gitignore-style syntax for excluding specific files in the future

@kylewlacy kylewlacy merged commit 279124a into main Aug 31, 2024
5 checks passed
@kylewlacy kylewlacy deleted the implement-glob-recipe branch August 31, 2024 22:25
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.

Add a recipe to glob a directory
1 participant