Skip to content

Commit 697f056

Browse files
committed
fix: scan past non-replace layers to find base in resolve_content
The base-finding scan now skips non-replace layers below a replace layer instead of stopping at the first non-replace. This fixes the case where a low-priority append/prepend layer sits below a replace that should serve as the base for composition.
1 parent 2437d7a commit 697f056

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/specify_cli/presets.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,16 +2875,20 @@ def resolve_content(
28752875
# layers is ordered highest-priority first. We process in reverse.
28762876
reversed_layers = list(reversed(layers))
28772877

2878-
# Find the base content: the first "replace" layer from the bottom
2878+
# Find the base content: scan bottom-up for the highest-priority
2879+
# "replace" layer that can serve as a base. Non-replace layers below
2880+
# the base are irrelevant (they have nothing to compose onto).
28792881
content = None
28802882
start_idx = 0
28812883
for i, layer in enumerate(reversed_layers):
28822884
if layer["strategy"] == "replace":
28832885
content = layer["path"].read_text(encoding="utf-8")
28842886
start_idx = i + 1
2885-
else:
2886-
# Once we hit a non-replace layer, stop looking for base
2887+
elif content is not None:
2888+
# Found a non-replace layer above a replace — stop scanning.
2889+
# The replace layer(s) form the base; composition starts here.
28872890
break
2891+
# Non-replace layers below any replace are skipped (no base yet)
28882892

28892893
# If no base content found, there's nothing to compose onto
28902894
if content is None:

0 commit comments

Comments
 (0)