cmds.secrets.FilesContext: Fix attrs precedence and macro scanning #155

Merged
Jan Lindemann merged 2 commits from jan/fix/20261024-cmds-secrets-filescontext-fix-attrs-precedence-and-macro-scanning into master 2026-10-24 22:27:50 +02:00 AGit
Owner

This PR fixes two defects in the secrets template compiler: the attribute precedence the operator set in the .jw-secret is restored, and commented-out macros no longer fail the compile:

cmds.secrets.FilesContext: Re-shuffle attrs precedence

_compile_one_template_file() re-parses the template's own conf line and, when present, discards the attrs that compile_template_file() merged from the command-line defaults, the template, the .jw-secret-file, and the .jw-secret. The merge already orders the sources so that later non-empty fields override earlier ones; discarding it inverts the order and lets the template's line override the one the operator placed in the .jw-secret.

Strip the template's conf line from the content and apply the merged attrs instead, so the .jw-secret conf line takes the last word again, as the compiler did before the rewrite. The integration test gains a target whose template and secret both carry a conf line.

cmds.secrets.FilesContext: Ignore commented-out macros

The unresolved-macro check scans the substituted content for __MACRO__ names, and a commented-out reference fails the compile like a live one. A disabled config section keeps its macros in the comments as documentation, and the matching store keys are retired along with it, so compiling the template fails on lines that no longer take effect.

Skip comment lines when scanning for unresolved macros. The integration test gains a target whose template carries a commented-out macro without a store entry.

This PR fixes two defects in the secrets template compiler: the attribute precedence the operator set in the `.jw-secret` is restored, and commented-out macros no longer fail the compile: #### cmds.secrets.FilesContext: Re-shuffle attrs precedence `_compile_one_template_file()` re-parses the template's own conf line and, when present, discards the attrs that `compile_template_file()` merged from the command-line defaults, the template, the `.jw-secret-file`, and the `.jw-secret`. The merge already orders the sources so that later non-empty fields override earlier ones; discarding it inverts the order and lets the template's line override the one the operator placed in the `.jw-secret`. Strip the template's conf line from the content and apply the merged attrs instead, so the `.jw-secret` conf line takes the last word again, as the compiler did before the rewrite. The integration test gains a target whose template and secret both carry a conf line. #### cmds.secrets.FilesContext: Ignore commented-out macros The unresolved-macro check scans the substituted content for `__MACRO__` names, and a commented-out reference fails the compile like a live one. A disabled config section keeps its macros in the comments as documentation, and the matching store keys are retired along with it, so compiling the template fails on lines that no longer take effect. Skip comment lines when scanning for unresolved macros. The integration test gains a target whose template carries a commented-out macro without a store entry.
_compile_one_template_file() re-parses the template's own conf line and,
when present, discards the attrs that compile_template_file() merged from
the command-line defaults, the template, the .jw-secret-file, and the
.jw-secret. The merge already orders the sources so that later non-empty
fields override earlier ones; discarding it inverts the order and lets the
template's line override the one the operator placed in the .jw-secret.

Strip the template's conf line from the content and apply the merged attrs
instead, so the .jw-secret conf line takes the last word again, as the
compiler did before the rewrite. The integration test gains a target whose
template and secret both carry a conf line.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
cmds.secrets.FilesContext: Ignore commented-out macros
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m37s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m6s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m39s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m54s
CI / Packaging test (push) Successful in 0s
6398406a5f
The unresolved-macro check scans the substituted content for __MACRO__
names, and a commented-out reference fails the compile like a live one. A
disabled config section keeps its macros in the comments as documentation,
and the matching store keys are retired along with it, so compiling the
template fails on lines that no longer take effect.

Skip comment lines when scanning for unresolved macros. The integration
test gains a target whose template carries a commented-out macro without a
store entry.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-10-24 22:10:23 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!155
No description provided.