hey devs. I can’t find if we already do this anywh...
# development
f
hey devs. I can’t find if we already do this anywhere else in Pants. I have a list of files from
hydrated_sources.snapshot.files
. Now I’d like to copy them (while preserving the inner directory hierarchy) into a new, temporary directory that needs to exist on disk. I’ll need to pass that directory path to a binary tool. Can I access such a location in some temporary build directory somewhere?
f
The
Digest
for those source files would be passed as the
input_digest
of the
Process
used to invoke the the binary tool.
that is, use
hydrated_sources.snapshot.digest
as part of forming the input digest to the process invocation
the files will be copied into the execution sandbox during the invoation
c
Also used in the docker backend for the docker build context..
For example ;)
f
oh thanks @fast-nail-55400! Sorry, I wasn’t clear. I already use the
.digest
and it works great. I was thinking about the use case where I have files
foo/dir/bar.txt
and
baz/dir/qwe.txt
(as part of the digest). Now I wanted to merge them onto
result/dir
directory containing both
bar.txt
and
qwe.txt
so that I could pass
result
directory name to the
Process
. After experimenting, I feel it may be unnecessary, but since I’ve asked, it would be handy to know whether there is an easy/sensible way to achieve that.
f
You can use
AddPrefix
and other digest manipulation types to modify the digest.
👍 1
h
Yeah,
Digest
is the "handle" around those files. See https://www.pantsbuild.org/docs/rules-api-file-system for how you can do things like rename files