hundreds-father-404
10/06/2021, 3:38 PMPaths.dirs
and Snapshot.dirs
to only include the dir names where there was a match? if you have only the file some_dir/subdir/f.go
and the glob **/*.go
, it will include some_dir
when I only want some_dir/subdir
happy-kitchen-89482
10/06/2021, 3:39 PMhundreds-father-404
10/06/2021, 3:44 PMpaths.dirs
dir_to_filenames = group_by_dir(go_paths.files)
dirs_with_go_files = []
for dir, filenames in dir_to_filenames.items():
if any(filename.endswith(".go") for filename in filenames):
dirs_with_go_files.append(dir)
We're duplicating it in Terraform target gen toowitty-crayon-22786
10/06/2021, 5:20 PMhundreds-father-404
10/06/2021, 5:30 PMwitty-crayon-22786
10/06/2021, 5:34 PMhundreds-father-404
10/06/2021, 5:37 PMeven more reason to consider replacing capturing dirs with recursive behavior.Why change our Rust code to do that? Wouldn't the calling code simply use
**/*
for the glob? I'm talking about the behavior of the Rust intrinsicwitty-crayon-22786
10/06/2021, 5:37 PM./pants test $dir
is going to be recursive, aligning our path/source globs could make sense semanticallyhundreds-father-404
10/06/2021, 5:40 PMdir
into dir/**
. We need to retain the ability to have a glob only for the directory and not recurse, *.go
vs **/*.go
Maybe I'm misunderstanding your suggestion?witty-crayon-22786
10/06/2021, 5:40 PMPaths.dirs
list, because the reason you would have matched would be for recursionhundreds-father-404
10/06/2021, 5:43 PMyou’re thinking of the rulesIndeed, I'm solely talking about the behavior of our intrisinics
Paths
and Snapshot
, how their .dirs
field works
We can change our user semantics to have dir
translate to dir/**
without changing our engine code
because the reason you would have matched would be for recursionFor those two callers perhaps, but there are other cases where it's helpful to have the list of dirs with a match, like my Go target gen idea
witty-crayon-22786
10/06/2021, 5:45 PMonly include the dir names where there was a match? if you have only thei don’t know how these semantics would work:and the globfile some_dir/subdir/f.go
, it will include**/*.go
when I only wantsome_dir
some_dir/subdir
some_dir
doesn’t actually match the glob you specified**/somedir
would, ***/**
would, etcos.path.dirname
the matches…?hundreds-father-404
10/06/2021, 5:49 PMsome_dir/subdir/f.go
, .dirs
will include some_dir
and some_dir/subdir
. It includes all directories seen in the resolved files
I'm proposing to instead only have the directories that contain a matched file. There is a matched file in some_dir/subdir/f.py
, so include some_dir/subdir
. There is no matched file in some_dir
, so leave it off.
It's not that the directory itself was in the glob, it's that the dir has a matched filewitty-crayon-22786
10/06/2021, 5:49 PMdirname
hundreds-father-404
10/06/2021, 5:49 PMPathGlobs
. Only Paths.dirs
That is dirnameIt is, indeed! Which is what this snippet does:
dir_to_filenames = group_by_dir(go_paths.files)
dirs_with_go_files = []
for dir, filenames in dir_to_filenames.items():
if any(filename.endswith(".go") for filename in filenames):
dirs_with_go_files.append(dir)
But I'm proposing it would be useful for the engine to calculate that for you already, rather than all this Python support code