Current working directory during copier {copy,recopy,update}
should be destination path
#1708
Labels
Milestone
copier {copy,recopy,update}
should be destination path
#1708
Describe the problem
While reimplementing
jinja-ansible-filters
(see #1398) – specifically testing thefileglob
filter –, I noticed that the current working directory while rendering template files throughcopier {copy,recopy,update}
is the directory from which the command is executed, but I think it should be the destination path; otherwise, thefileglob
filter (and other custom filesystem-based Jinja filters) wouldn't be particularly useful. WDYT?Template
example.zip
The filesystem layout is as follows:
The example assumes that
src/
contains a template from which a subproject will be generated intodst/
, which already contains files (e.g., from another Copier template).To Reproduce
Extract the content of the reproducible example in the ZIP archive above.
Change your current working directory to the root directory where you extracted the archive (i.e. where the file
cwd.txt
is located).Run
copier copy src/ dst/
.Note the content of the generated file
dst/fileglob.txt
:As you can see, the file
cwd.txt
is listed as a result of{{ '*.txt' | fileglob }}
.Logs
No response
Expected behavior
I'd expect the following behavior:
I.e., filesystem-related Jinja filters should operate relative to the destination path.
That said, filesystem-related Jinja filters operating on the destination path may lead to unexpected behavior because Copier will generate files in arbitrary order, so the output of the
fileglob
filter may not be consistent across multiple runs.Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu 22.04
Copier version
9.3.1
Python version
CPython 3.12
Installation method
pipx+pypi
Additional context
No response
The text was updated successfully, but these errors were encountered: