I'm currently working on pre-call filtering on module call (https://github.com/dagger/dagger/issues/9490) and I noticied that my tests on Python was failing.
I made a repro and found out that Include and Exclude on WithDirectory are not working the same way as the ignore pattern.
Example:
//+ignore=["**", "!main.go"] <- ignore everything except main.go
But if I do convert that to a withDirectory, it's just ignoring everything
func (t *Test) TestDir() *dagger.Directory {
dir := dag.Directory().WithNewFile("go.sum", "foo").WithNewFile("main.go", "bar")
return dag.Directory().WithDirectory("/", dir, dagger.DirectoryWithDirectoryOpts{
Include: []string{"main.go"},
Exclude: []string{"**"},
})
}
This will return an empty directory.
If I only set Include, then it's going to only pick up main.go.
That means that to support preload I need to check if the list contains !, if it does, only include them.
But that's wrong because you might ignore a subdirectory but include a specific file and still want the rest.
Like ["subdir/**", "!subdir/foo.txt"] -> which can be translated to include everything except subdir excluding subdir/foo.txt that should be included
So I'm a bit stuck, how should I handle that resolution?