-
Notifications
You must be signed in to change notification settings - Fork 290
fix: support input globs #3812
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
fix: support input globs #3812
Conversation
@@ -72,25 +75,55 @@ impl<'t> GlobSet<'t> { | |||
.include | |||
.iter() | |||
.flat_map(move |glob| { | |||
glob.walk(root_dir.clone()) | |||
let (effective_walk_root, glob) = if glob.has_semantic_literals() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is basically new behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that check really necessary?
Can't you always use partition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - let's take an example that we have pixi.toml
glob
Calling partition on it, we will receive
pixi.toml
prefix and empty glob, which when walking
will not match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Nichita!
I left a few comments :)
crates/pixi_glob/src/glob_set.rs
Outdated
#[test] | ||
fn test_filters_with_just_a_file_glob() { | ||
let temp_dir = tempdir().unwrap(); | ||
let root_path = temp_dir.path(); | ||
|
||
// Create files and directories | ||
File::create(root_path.join("pixi.toml")).unwrap(); | ||
|
||
// Test globs: include all .txt but exclude exclude.txt | ||
let filter_globs = GlobSet::create(vec!["pixi.toml", "!exclude.txt"]).unwrap(); | ||
|
||
// Filter directory and get results as strings | ||
let mut filtered_files: Vec<_> = filter_globs | ||
// pretend that we are in the workspace folder | ||
// and our recipe yaml is living inside some folder | ||
// that will point outside | ||
.filter_directory(root_path) | ||
.collect::<Result<Vec<_>, _>>() | ||
.unwrap() | ||
.into_iter() | ||
.map(|p| p.path().strip_prefix(root_path).unwrap().to_path_buf()) | ||
.collect(); | ||
|
||
// Assert the expected files are present | ||
filtered_files.sort(); | ||
|
||
let expected = vec!["pixi.toml".parse::<PathBuf>().unwrap()]; | ||
assert_eq!(filtered_files, expected); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't have a glob with ..
in front.
Why did you add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to test this edge case:
#3812 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay!
@@ -72,25 +75,55 @@ impl<'t> GlobSet<'t> { | |||
.include | |||
.iter() | |||
.flat_map(move |glob| { | |||
glob.walk(root_dir.clone()) | |||
let (effective_walk_root, glob) = if glob.has_semantic_literals() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that check really necessary?
Can't you always use partition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, then we can bring it in :)
Co-authored-by: Hofer-Julian <[email protected]>
Fixes:
#3778
Overview
The idea is that sometimes, we can have
semantic
input globs.What do we mean by semantic? Semantic is something that has a special meaning on different platforms.
Example:
../*.toml
- in this case,..
is a semantic prefix, and it doesn't have therelative
meaning for glob patterns. Ourwax
will try to match..
as a wrong file.In this PR, we start checking if we have some semantic prefix - if yes, we
partition
it in two pieces - a prefix and a new glob, and create a neweffective_walk_root
which is the previous root_path + prefix.How to test it?
You can create a structure where you have a workspace in pixi.toml, then in some
sources
folder another packagepixi.toml
which will use pixi-build-rattler-build with arecipe.yaml
that points somewhere relative.When running
pixi install
(pixi build
will not trigger this code path ),pixi-build-rattler-build
will emit a relative glob that will be used, for example, for caching.