Open AtomToast opened 1 month ago
@AtomToast It's in the code at https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/yadm#L429 and the test to confirm it works is at https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/test/test_unit_template_default.py#L246 Do other vars get substituted correctly?
On my system, env.HOME substitutes correctly. Ubuntu 24.04 and
$ yadm version
bash version 5.2.21(1)-release
git version 2.43.0
yadm version 3.2.2
$ awk --version| head -n 1
GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)
Please correct me if I'm wrong but to me this is again only the variable substitution part of the code. This works for me.
What doesn't work for me are if blocks. As per https://yadm.io/docs/templates, in the if-else-endif
section.
@AtomToast Good point. I haven't tested it, but the env.
logic is the same as the other yadm.
so I am really surprised it's not working. See https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/yadm#L426-L431
For me this is 100% reproducable.
The code you linked is part of the replaces_vars()
function, which does not seem to be called in the conditions()
function.
There all I can see is this https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/yadm#L441 which I believe is the yadm.
part of the logic? There is no EVIRON[label]
call
@AtomToast You are correct. Just below https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/yadm#L439-L444 we need to add
for (label in ENVIRON) {
value = ENVIRON[label]
pattern = sprintf("%s%s|", pattern, condition_helper(label, value));
}
That alone seems to not have done it for me. Is there perhaps something else missing?
Describe the bug
Similarly to #486, trying to use env variables in
{% if env.EXAMPLE == "example" %}
with the default template processor does not work.To reproduce
Can this be reproduced with the yadm/testbed docker image: Yes script.gz
Steps to reproduce the behavior:
export TEST=testing
yadm add test.txt##template
cat test.txt
Expected behavior
The file should contain
success
, however instead it uses thefail
branch.Environment
Additional context
From a brief look at the code, it seems that this is actually just not implemented right now?