Skip to content

Commit c11b2f4

Browse files
committed
fix: address twelfth round of Copilot PR review feedback
- Persist normalized strategy: write lowercase value back to tmpl dict so downstream composition logic always sees lowercase - Normalize strategy in PowerShell: .ToLowerInvariant() after parsing - Fix bash tab parsing: use IFS+read instead of parameter expansion to avoid trailing newline in manifest_file; normalize with ${strategy,,} - Gate CLI composition message: only show 'Final output is composed...' when the top layer is non-replace (top replace wins outright)
1 parent c9ffcc1 commit c11b2f4

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

scripts/bash/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ try:
441441
except Exception:
442442
print('replace\t')
443443
" 2>/dev/null) && {
444-
strategy="${result%% *}"
445-
manifest_file="${result#* }"
444+
IFS=$'\t' read -r strategy manifest_file <<< "$result"
445+
strategy="${strategy,,}" # normalize to lowercase
446446
}
447447
fi
448448
# Try manifest file path first, then convention path

scripts/powershell/common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ except Exception:
443443
"@ $manifest $TemplateName 2>$null
444444
if ($stratResult) {
445445
$parts = $stratResult.Trim() -split "`t", 2
446-
$strategy = $parts[0]
446+
$strategy = $parts[0].ToLowerInvariant()
447447
if ($parts.Count -gt 1 -and $parts[1]) { $manifestFilePath = $parts[1] }
448448
}
449449
} catch {

src/specify_cli/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,10 @@ def preset_resolve(
26062606
console.print(f" [bold]{template_name}[/bold]: {display_layer['path']}")
26072607
console.print(f" [dim](top layer from: {display_layer['source']})[/dim]")
26082608

2609-
has_composition = any(layer["strategy"] != "replace" for layer in layers)
2609+
has_composition = (
2610+
layers[0]["strategy"] != "replace"
2611+
and any(layer["strategy"] != "replace" for layer in layers)
2612+
)
26102613
if has_composition:
26112614
console.print(" [dim]Final output is composed from multiple preset layers; the path above is the highest-priority contributing layer.[/dim]")
26122615
console.print("\n [bold]Composition chain:[/bold]")

src/specify_cli/presets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def _validate(self):
162162
f"got {type(strategy).__name__}"
163163
)
164164
strategy = strategy.lower()
165+
# Persist normalized value so downstream code sees lowercase
166+
if "strategy" in tmpl:
167+
tmpl["strategy"] = strategy
165168
if strategy not in VALID_PRESET_STRATEGIES:
166169
raise PresetValidationError(
167170
f"Invalid strategy '{strategy}': "

0 commit comments

Comments
 (0)